Skip to content

Commit

Permalink
Merge pull request #341 from takapi327/refactor/2024-12-Change-test-s…
Browse files Browse the repository at this point in the history
…pecs2-to-scalatest

Refactor/2024 12 change test specs2 to scalatest
  • Loading branch information
takapi327 authored Dec 21, 2024
2 parents 93e1ab9 + 74d6fc5 commit 7e5ea57
Show file tree
Hide file tree
Showing 11 changed files with 674 additions and 625 deletions.
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

0 comments on commit 7e5ea57

Please sign in to comment.