Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/2024 12 change test specs2 to scalatest #341

Merged
merged 14 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ lazy val codegen = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.settings(
libraryDependencies ++= Seq(
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.3.0",
"org.scalatest" %%% "scalatest" % "3.2.18" % Test,
"org.specs2" %%% "specs2-core" % "4.20.5" % Test
"org.typelevel" %%% "munit-cats-effect" % "2.0.0" % Test
)
)
.jvmSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,132 +6,157 @@

package ldbc.codegen.builder

import org.specs2.mutable.Specification
import munit.CatsEffectSuite

import ldbc.codegen.formatter.Naming
import ldbc.codegen.model.*
import ldbc.codegen.model.ColumnDefinition.*

object ColumnCodeBuilderTest extends Specification:
class ColumnCodeBuilderTest extends CatsEffectSuite:

private val builder = ColumnCodeBuilder(Naming.PASCAL)

"Testing the ColumnCodeBuilder" should {
"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition("p1", DataType.VARCHAR(255, None, None), None)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition("p1", DataType.VARCHAR(255, None, None), None)
assertEquals(
builder.build(
column,
None
) === "def p1: Column[Option[String]] = column[Option[String]](\"p1\", VARCHAR[Option[String]](255))"
}
),
"def p1: Column[Option[String]] = column[Option[String]](\"p1\", VARCHAR[Option[String]](255))"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition("p1", DataType.VARCHAR(255, None, None), Some(List(Attribute.Condition(false))))
builder.build(column, None) === "def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255))"
}
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition("p1", DataType.VARCHAR(255, None, None), Some(List(Attribute.Condition(false))))
assertEquals(
builder.build(column, None),
"def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255))"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition(
"p1",
DataType.BIGINT(None, false, false),
Some(
List(
Attribute.Condition(false),
Attribute.Key("AUTO_INCREMENT"),
Attribute.Key("PRIMARY_KEY")
)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition(
"p1",
DataType.BIGINT(None, false, false),
Some(
List(
Attribute.Condition(false),
Attribute.Key("AUTO_INCREMENT"),
Attribute.Key("PRIMARY_KEY")
)
)
)
assertEquals(
builder.build(
column,
None
) === "def p1: Column[Long] = column[Long](\"p1\", BIGINT[Long], AUTO_INCREMENT, PRIMARY_KEY)"
}
),
"def p1: Column[Long] = column[Long](\"p1\", BIGINT[Long], AUTO_INCREMENT, PRIMARY_KEY)"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition(
"p1",
DataType.BIGINT(None, false, false),
Some(
List(
Attribute.Condition(false),
CommentSet("identifier")
)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition(
"p1",
DataType.BIGINT(None, false, false),
Some(
List(
Attribute.Condition(false),
CommentSet("identifier")
)
)
)
assertEquals(
builder.build(
column,
None
) === "def p1: Column[Long] = column[Long](\"p1\", BIGINT[Long], COMMENT(\"identifier\"))"
}
),
"def p1: Column[Long] = column[Long](\"p1\", BIGINT[Long], COMMENT(\"identifier\"))"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.Collate("utf8mb4_bin")
)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.Collate("utf8mb4_bin")
)
)
)
assertEquals(
builder.build(
column,
None
) === "def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), Collate.utf8mb4_bin)"
}
),
"def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), Collate.utf8mb4_bin)"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.Visible("VISIBLE")
)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.Visible("VISIBLE")
)
)
builder.build(column, None) === "def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), VISIBLE)"
}
)
assertEquals(
builder.build(column, None),
"def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), VISIBLE)"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.ColumnFormat("FIXED")
)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.ColumnFormat("FIXED")
)
)
)
assertEquals(
builder.build(
column,
None
) === "def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), COLUMN_FORMAT.FIXED)"
}
),
"def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), COLUMN_FORMAT.FIXED)"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.Storage("DISK")
)
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition(
"p1",
DataType.VARCHAR(255, None, None),
Some(
List(
Attribute.Condition(false),
Attribute.Storage("DISK")
)
)
)
assertEquals(
builder.build(
column,
None
) === "def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), STORAGE.DISK)"
}
),
"def p1: Column[String] = column[String](\"p1\", VARCHAR[String](255), STORAGE.DISK)"
)
}

"The construction of Column into a code string matches the specified string." in {
val column = ColumnDefinition("p1", DataType.SERIAL(), None)
builder.build(column, None) === "def p1: Column[BigInt] = column[BigInt](\"p1\", SERIAL[BigInt])"
}
test("The construction of Column into a code string matches the specified string.") {
val column = ColumnDefinition("p1", DataType.SERIAL(), None)
assertEquals(
builder.build(column, None),
"def p1: Column[BigInt] = column[BigInt](\"p1\", SERIAL[BigInt])"
)
}
Loading
Loading