diff --git a/build.sbt b/build.sbt index 174549b19..496789dc0 100644 --- a/build.sbt +++ b/build.sbt @@ -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( diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/ColumnCodeBuilderTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/ColumnCodeBuilderTest.scala index 3ad6ef4b3..390fb621a 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/ColumnCodeBuilderTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/ColumnCodeBuilderTest.scala @@ -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])" + ) } diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/DataTypeCodeBuilderTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/DataTypeCodeBuilderTest.scala index 0cf0c4a8e..419f40da0 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/DataTypeCodeBuilderTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/builder/DataTypeCodeBuilderTest.scala @@ -6,355 +6,384 @@ package ldbc.codegen.builder -import org.specs2.mutable.Specification +import munit.CatsEffectSuite import ldbc.codegen.formatter.Naming import ldbc.codegen.model.DataType -object DataTypeCodeBuilderTest extends Specification: +class DataTypeCodeBuilderTest extends CatsEffectSuite: private def builder(scalaType: String) = DataTypeCodeBuilder(scalaType, Naming.PASCAL) - "Testing the DataTypeCodeBuilder" should { - "BIT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.BIT(None) - val dataType2 = DataType.BIT(Some(1)) - builder("Byte").build(dataType1) === "BIT[Byte]" and - builder("Option[Byte]").build(dataType1) === "BIT[Option[Byte]]" and - builder("Byte").build(dataType2) === "BIT[Byte](1)" and - builder("Option[Byte]").build(dataType2) === "BIT[Option[Byte]](1)" - } - - "TINYINT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.TINYINT(None, true, true) - val dataType2 = DataType.TINYINT(Some(1), false, true) - val dataType3 = DataType.TINYINT(None, true, false) - val dataType4 = DataType.TINYINT(Some(1), false, false) - builder("Short").build(dataType1) === "TINYINT[Short].UNSIGNED.ZEROFILL" and - builder("Option[Short]").build(dataType1) === "TINYINT[Option[Short]].UNSIGNED.ZEROFILL" and - builder("Short").build(dataType2) === "TINYINT[Short](1).ZEROFILL" and - builder("Option[Short]").build(dataType2) === "TINYINT[Option[Short]](1).ZEROFILL" and - builder("Short").build(dataType3) === "TINYINT[Short].UNSIGNED" and - builder("Option[Short]").build(dataType3) === "TINYINT[Option[Short]].UNSIGNED" and - builder("Short").build(dataType4) === "TINYINT[Short](1)" and - builder("Option[Short]").build(dataType4) === "TINYINT[Option[Short]](1)" - } - - "SMALLINT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.SMALLINT(None, true, true) - val dataType2 = DataType.SMALLINT(Some(1), false, true) - val dataType3 = DataType.SMALLINT(None, true, false) - val dataType4 = DataType.SMALLINT(Some(1), false, false) - builder("Int").build(dataType1) === "SMALLINT[Int].UNSIGNED.ZEROFILL" and - builder("Option[Int]").build(dataType1) === "SMALLINT[Option[Int]].UNSIGNED.ZEROFILL" and - builder("Int").build(dataType2) === "SMALLINT[Int](1).ZEROFILL" and - builder("Option[Int]").build(dataType2) === "SMALLINT[Option[Int]](1).ZEROFILL" and - builder("Int").build(dataType3) === "SMALLINT[Int].UNSIGNED" and - builder("Option[Int]").build(dataType3) === "SMALLINT[Option[Int]].UNSIGNED" and - builder("Int").build(dataType4) === "SMALLINT[Int](1)" and - builder("Option[Int]").build(dataType4) === "SMALLINT[Option[Int]](1)" - } - - "MEDIUMINT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.MEDIUMINT(None, true, true) - val dataType2 = DataType.MEDIUMINT(Some(1), false, true) - val dataType3 = DataType.MEDIUMINT(None, true, false) - val dataType4 = DataType.MEDIUMINT(Some(1), false, false) - builder("Int").build(dataType1) === "MEDIUMINT[Int].UNSIGNED.ZEROFILL" and - builder("Option[Int]").build(dataType1) === "MEDIUMINT[Option[Int]].UNSIGNED.ZEROFILL" and - builder("Int").build(dataType2) === "MEDIUMINT[Int](1).ZEROFILL" and - builder("Option[Int]").build(dataType2) === "MEDIUMINT[Option[Int]](1).ZEROFILL" and - builder("Int").build(dataType3) === "MEDIUMINT[Int].UNSIGNED" and - builder("Option[Int]").build(dataType3) === "MEDIUMINT[Option[Int]].UNSIGNED" and - builder("Int").build(dataType4) === "MEDIUMINT[Int](1)" and - builder("Option[Int]").build(dataType4) === "MEDIUMINT[Option[Int]](1)" - } - - "INT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.INT(None, true, true) - val dataType2 = DataType.INT(Some(1), false, true) - val dataType3 = DataType.INT(None, true, false) - val dataType4 = DataType.INT(Some(1), false, false) - builder("Int").build(dataType1) === "INT[Int].UNSIGNED.ZEROFILL" and - builder("Option[Int]").build(dataType1) === "INT[Option[Int]].UNSIGNED.ZEROFILL" and - builder("Int").build(dataType2) === "INT[Int](1).ZEROFILL" and - builder("Option[Int]").build(dataType2) === "INT[Option[Int]](1).ZEROFILL" and - builder("Int").build(dataType3) === "INT[Int].UNSIGNED" and - builder("Option[Int]").build(dataType3) === "INT[Option[Int]].UNSIGNED" and - builder("Int").build(dataType4) === "INT[Int](1)" and - builder("Option[Int]").build(dataType4) === "INT[Option[Int]](1)" - } - - "BIGINT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.BIGINT(None, true, true) - val dataType2 = DataType.BIGINT(Some(1), false, true) - val dataType3 = DataType.BIGINT(None, true, false) - val dataType4 = DataType.BIGINT(Some(1), false, false) - builder("BigInt").build(dataType1) === "BIGINT[BigInt].UNSIGNED.ZEROFILL" and - builder("Option[BigInt]").build(dataType1) === "BIGINT[Option[BigInt]].UNSIGNED.ZEROFILL" and - builder("BigInt").build(dataType2) === "BIGINT[BigInt](1).ZEROFILL" and - builder("Option[BigInt]").build(dataType2) === "BIGINT[Option[BigInt]](1).ZEROFILL" and - builder("BigInt").build(dataType3) === "BIGINT[BigInt].UNSIGNED" and - builder("Option[BigInt]").build(dataType3) === "BIGINT[Option[BigInt]].UNSIGNED" and - builder("BigInt").build(dataType4) === "BIGINT[BigInt](1)" and - builder("Option[BigInt]").build(dataType4) === "BIGINT[Option[BigInt]](1)" - } - - "DECIMAL DataType construction to code string matches the specified string." in { - val dataType1 = DataType.DECIMAL(10, 0, true, true) - val dataType2 = DataType.DECIMAL(10, 0, false, true) - val dataType3 = DataType.DECIMAL(10, 0, true, false) - val dataType4 = DataType.DECIMAL(10, 0, false, false) - builder("BigDecimal").build(dataType1) === "DECIMAL[BigDecimal](10, 0).UNSIGNED.ZEROFILL" and - builder("Option[BigDecimal]").build(dataType1) === "DECIMAL[Option[BigDecimal]](10, 0).UNSIGNED.ZEROFILL" and - builder("BigDecimal").build(dataType2) === "DECIMAL[BigDecimal](10, 0).ZEROFILL" and - builder("Option[BigDecimal]").build(dataType2) === "DECIMAL[Option[BigDecimal]](10, 0).ZEROFILL" and - builder("BigDecimal").build(dataType3) === "DECIMAL[BigDecimal](10, 0).UNSIGNED" and - builder("Option[BigDecimal]").build(dataType3) === "DECIMAL[Option[BigDecimal]](10, 0).UNSIGNED" and - builder("BigDecimal").build(dataType4) === "DECIMAL[BigDecimal](10, 0)" and - builder("Option[BigDecimal]").build(dataType4) === "DECIMAL[Option[BigDecimal]](10, 0)" - } - - "FLOAT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.FLOAT(10, true, true) - val dataType2 = DataType.FLOAT(10, false, true) - val dataType3 = DataType.FLOAT(10, true, false) - val dataType4 = DataType.FLOAT(10, false, false) - builder("Float").build(dataType1) === "FLOAT[Float](10).UNSIGNED.ZEROFILL" and - builder("Option[Float]").build(dataType1) === "FLOAT[Option[Float]](10).UNSIGNED.ZEROFILL" and - builder("Float").build(dataType2) === "FLOAT[Float](10).ZEROFILL" and - builder("Option[Float]").build(dataType2) === "FLOAT[Option[Float]](10).ZEROFILL" and - builder("Float").build(dataType3) === "FLOAT[Float](10).UNSIGNED" and - builder("Option[Float]").build(dataType3) === "FLOAT[Option[Float]](10).UNSIGNED" and - builder("Float").build(dataType4) === "FLOAT[Float](10)" and - builder("Option[Float]").build(dataType4) === "FLOAT[Option[Float]](10)" - } - - "CHAR DataType construction to code string matches the specified string." in { - val dataType1 = DataType.CHAR(255, Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.CHAR(255, Some("utf8mb4"), None) - val dataType3 = DataType.CHAR(255, None, Some("utf8mb4_bin")) - val dataType4 = DataType.CHAR(255, None, None) - builder("String").build( - dataType1 - ) === "CHAR[String](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build( - dataType1 - ) === "CHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType2) === "CHAR[String](255).CHARACTER_SET(Character.utf8mb4)" and - builder("Option[String]").build(dataType2) === "CHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4)" and - builder("String").build(dataType3) === "CHAR[String](255).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build(dataType3) === "CHAR[Option[String]](255).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType4) === "CHAR[String](255)" and - builder("Option[String]").build(dataType4) === "CHAR[Option[String]](255)" - } - - "VARCHAR DataType construction to code string matches the specified string." in { - val dataType1 = DataType.VARCHAR(255, Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.VARCHAR(255, Some("utf8mb4"), None) - val dataType3 = DataType.VARCHAR(255, None, Some("utf8mb4_bin")) - val dataType4 = DataType.VARCHAR(255, None, None) - builder("String").build( - dataType1 - ) === "VARCHAR[String](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build( - dataType1 - ) === "VARCHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType2) === "VARCHAR[String](255).CHARACTER_SET(Character.utf8mb4)" and - builder("Option[String]").build( - dataType2 - ) === "VARCHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4)" and - builder("String").build(dataType3) === "VARCHAR[String](255).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build(dataType3) === "VARCHAR[Option[String]](255).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType4) === "VARCHAR[String](255)" and - builder("Option[String]").build(dataType4) === "VARCHAR[Option[String]](255)" - } - - "BINARY DataType construction to code string matches the specified string." in { - val dataType = DataType.BINARY(255) - builder("String").build(dataType) === "BINARY[String](255)" and - builder("Option[String]").build(dataType) === "BINARY[Option[String]](255)" - } - - "VARBINARY DataType construction to code string matches the specified string." in { - val dataType = DataType.VARBINARY(255) - builder("Array[Byte]").build(dataType) === "VARBINARY[Array[Byte]](255)" and - builder("Option[Array[Byte]]").build(dataType) === "VARBINARY[Option[Array[Byte]]](255)" - } - - "TINYBLOB DataType construction to code string matches the specified string." in { - val dataType = DataType.TINYBLOB() - builder("Array[Byte]").build(dataType) === "TINYBLOB[Array[Byte]]()" and - builder("Option[Array[Byte]]").build(dataType) === "TINYBLOB[Option[Array[Byte]]]()" - } - - "TINYTEXT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.TINYTEXT(Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.TINYTEXT(Some("utf8mb4"), None) - val dataType3 = DataType.TINYTEXT(None, Some("utf8mb4_bin")) - val dataType4 = DataType.TINYTEXT(None, None) - builder("String").build( - dataType1 - ) === "TINYTEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build( - dataType1 - ) === "TINYTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType2) === "TINYTEXT[String]().CHARACTER_SET(Character.utf8mb4)" and - builder("Option[String]").build(dataType2) === "TINYTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" and - builder("String").build(dataType3) === "TINYTEXT[String]().COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build(dataType3) === "TINYTEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType4) === "TINYTEXT[String]()" and - builder("Option[String]").build(dataType4) === "TINYTEXT[Option[String]]()" - } - - "ENUM DataType construction to code string matches the specified string." in { - val dataType1 = DataType.ENUM(List("Active", "InActive"), Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.ENUM(List("Active", "InActive"), Some("utf8mb4"), None) - val dataType3 = DataType.ENUM(List("Active", "InActive"), None, Some("utf8mb4_bin")) - val dataType4 = DataType.ENUM(List("Active", "InActive"), None, None) - builder("Status").build( - dataType1 - ) === "ENUM[Status](using Status).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[Status]").build( - dataType1 - ) === "ENUM[Option[Status]](using Status).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Status").build(dataType2) === "ENUM[Status](using Status).CHARACTER_SET(Character.utf8mb4)" and - builder("Option[Status]").build( - dataType2 - ) === "ENUM[Option[Status]](using Status).CHARACTER_SET(Character.utf8mb4)" and - builder("Status").build(dataType3) === "ENUM[Status](using Status).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[Status]").build( - dataType3 - ) === "ENUM[Option[Status]](using Status).COLLATE(Collate.utf8mb4_bin)" and - builder("Status").build(dataType4) === "ENUM[Status](using Status)" and - builder("Option[Status]").build(dataType4) === "ENUM[Option[Status]](using Status)" - } - - "BLOB DataType construction to code string matches the specified string." in { - val dataType1 = DataType.BLOB(Some(255)) - val dataType2 = DataType.BLOB(None) - builder("Array[Byte]").build(dataType1) === "BLOB[Array[Byte]](255)" and - builder("Option[Array[Byte]]").build(dataType1) === "BLOB[Option[Array[Byte]]](255)" and - builder("Array[Byte]").build(dataType2) === "BLOB[Array[Byte]]()" and - builder("Option[Array[Byte]]").build(dataType2) === "BLOB[Option[Array[Byte]]]()" - } - - "TEXT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.TEXT(Some(255), Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.TEXT(None, Some("utf8mb4"), None) - val dataType3 = DataType.TEXT(Some(255), None, Some("utf8mb4_bin")) - val dataType4 = DataType.TEXT(None, None, None) - builder("String").build( - dataType1 - ) === "TEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build( - dataType1 - ) === "TEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType2) === "TEXT[String]().CHARACTER_SET(Character.utf8mb4)" and - builder("Option[String]").build(dataType2) === "TEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" and - builder("String").build(dataType3) === "TEXT[String]().COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build(dataType3) === "TEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType4) === "TEXT[String]()" and - builder("Option[String]").build(dataType4) === "TEXT[Option[String]]()" - } - - "MEDIUMBLOB DataType construction to code string matches the specified string." in { - val dataType = DataType.MEDIUMBLOB() - builder("Array[Byte]").build(dataType) === "MEDIUMBLOB[Array[Byte]]()" and - builder("Option[Array[Byte]]").build(dataType) === "MEDIUMBLOB[Option[Array[Byte]]]()" - } - - "MEDIUMTEXT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.MEDIUMTEXT(Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.MEDIUMTEXT(Some("utf8mb4"), None) - val dataType3 = DataType.MEDIUMTEXT(None, Some("utf8mb4_bin")) - val dataType4 = DataType.MEDIUMTEXT(None, None) - builder("String").build( - dataType1 - ) === "MEDIUMTEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build( - dataType1 - ) === "MEDIUMTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType2) === "MEDIUMTEXT[String]().CHARACTER_SET(Character.utf8mb4)" and - builder("Option[String]").build( - dataType2 - ) === "MEDIUMTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" and - builder("String").build(dataType3) === "MEDIUMTEXT[String]().COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build(dataType3) === "MEDIUMTEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType4) === "MEDIUMTEXT[String]()" and - builder("Option[String]").build(dataType4) === "MEDIUMTEXT[Option[String]]()" - } - - "LONGBLOB DataType construction to code string matches the specified string." in { - val dataType = DataType.LONGBLOB() - builder("Array[Byte]").build(dataType) === "LONGBLOB[Array[Byte]]()" and - builder("Option[Array[Byte]]").build(dataType) === "LONGBLOB[Option[Array[Byte]]]()" - } - - "LONGTEXT DataType construction to code string matches the specified string." in { - val dataType1 = DataType.LONGTEXT(Some("utf8mb4"), Some("utf8mb4_bin")) - val dataType2 = DataType.LONGTEXT(Some("utf8mb4"), None) - val dataType3 = DataType.LONGTEXT(None, Some("utf8mb4_bin")) - val dataType4 = DataType.LONGTEXT(None, None) - builder("String").build( - dataType1 - ) === "LONGTEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build( - dataType1 - ) === "LONGTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType2) === "LONGTEXT[String]().CHARACTER_SET(Character.utf8mb4)" and - builder("Option[String]").build(dataType2) === "LONGTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" and - builder("String").build(dataType3) === "LONGTEXT[String]().COLLATE(Collate.utf8mb4_bin)" and - builder("Option[String]").build(dataType3) === "LONGTEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)" and - builder("String").build(dataType4) === "LONGTEXT[String]()" and - builder("Option[String]").build(dataType4) === "LONGTEXT[Option[String]]()" - } - - "DATE DataType construction to code string matches the specified string." in { - val dataType = DataType.DATE() - builder("LocalDate").build(dataType) === "DATE[LocalDate]" and - builder("Option[LocalDate]").build(dataType) === "DATE[Option[LocalDate]]" - } - - "DATETIME DataType construction to code string matches the specified string." in { - val dataType1 = DataType.DATETIME(Some(6)) - val dataType2 = DataType.DATETIME(None) - builder("LocalDateTime").build(dataType1) === "DATETIME[LocalDateTime](6)" and - builder("Option[LocalDateTime]").build(dataType1) === "DATETIME[Option[LocalDateTime]](6)" and - builder("LocalDateTime").build(dataType2) === "DATETIME[LocalDateTime]" and - builder("Option[LocalDateTime]").build(dataType2) === "DATETIME[Option[LocalDateTime]]" - } - - "TIMESTAMP DataType construction to code string matches the specified string." in { - val dataType1 = DataType.TIMESTAMP(Some(6)) - val dataType2 = DataType.TIMESTAMP(None) - builder("LocalDateTime").build(dataType1) === "TIMESTAMP[LocalDateTime](6)" and - builder("Option[LocalDateTime]").build(dataType1) === "TIMESTAMP[Option[LocalDateTime]](6)" and - builder("LocalDateTime").build(dataType2) === "TIMESTAMP[LocalDateTime]" and - builder("Option[LocalDateTime]").build(dataType2) === "TIMESTAMP[Option[LocalDateTime]]" - } - - "TIME DataType construction to code string matches the specified string." in { - val dataType1 = DataType.TIME(Some(6)) - val dataType2 = DataType.TIME(None) - builder("LocalTime").build(dataType1) === "TIME[LocalTime](6)" and - builder("Option[LocalTime]").build(dataType1) === "TIME[Option[LocalTime]](6)" and - builder("LocalTime").build(dataType2) === "TIME[LocalTime]" and - builder("Option[LocalTime]").build(dataType2) === "TIME[Option[LocalTime]]" - } - - "YEAR DataType construction to code string matches the specified string." in { - val dataType1 = DataType.YEAR(Some(4)) - val dataType2 = DataType.YEAR(None) - builder("Year").build(dataType1) === "YEAR[Year](4)" and - builder("Option[Year]").build(dataType1) === "YEAR[Option[Year]](4)" and - builder("Year").build(dataType2) === "YEAR[Year]" and - builder("Option[Year]").build(dataType2) === "YEAR[Option[Year]]" - } - - "SERIAL DataType construction to code string matches the specified string." in { - val dataType = DataType.SERIAL() - builder("BigInt").build(dataType) === "SERIAL[BigInt]" and - builder("Option[BigInt]").build(dataType) === "SERIAL[BigInt]" - } + test("BIT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.BIT(None) + val dataType2 = DataType.BIT(Some(1)) + assertEquals(builder("Byte").build(dataType1), "BIT[Byte]") + assertEquals(builder("Option[Byte]").build(dataType1), "BIT[Option[Byte]]") + assertEquals(builder("Byte").build(dataType2), "BIT[Byte](1)") + assertEquals(builder("Option[Byte]").build(dataType2), "BIT[Option[Byte]](1)") + } + + test("TINYINT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.TINYINT(None, true, true) + val dataType2 = DataType.TINYINT(Some(1), false, true) + val dataType3 = DataType.TINYINT(None, true, false) + val dataType4 = DataType.TINYINT(Some(1), false, false) + assertEquals(builder("Short").build(dataType1), "TINYINT[Short].UNSIGNED.ZEROFILL") + assertEquals(builder("Option[Short]").build(dataType1), "TINYINT[Option[Short]].UNSIGNED.ZEROFILL") + assertEquals(builder("Short").build(dataType2), "TINYINT[Short](1).ZEROFILL") + assertEquals(builder("Option[Short]").build(dataType2), "TINYINT[Option[Short]](1).ZEROFILL") + assertEquals(builder("Short").build(dataType3), "TINYINT[Short].UNSIGNED") + assertEquals(builder("Option[Short]").build(dataType3), "TINYINT[Option[Short]].UNSIGNED") + assertEquals(builder("Short").build(dataType4), "TINYINT[Short](1)") + assertEquals(builder("Option[Short]").build(dataType4), "TINYINT[Option[Short]](1)") + } + + test("SMALLINT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.SMALLINT(None, true, true) + val dataType2 = DataType.SMALLINT(Some(1), false, true) + val dataType3 = DataType.SMALLINT(None, true, false) + val dataType4 = DataType.SMALLINT(Some(1), false, false) + assertEquals(builder("Int").build(dataType1), "SMALLINT[Int].UNSIGNED.ZEROFILL") + assertEquals(builder("Option[Int]").build(dataType1), "SMALLINT[Option[Int]].UNSIGNED.ZEROFILL") + assertEquals(builder("Int").build(dataType2), "SMALLINT[Int](1).ZEROFILL") + assertEquals(builder("Option[Int]").build(dataType2), "SMALLINT[Option[Int]](1).ZEROFILL") + assertEquals(builder("Int").build(dataType3), "SMALLINT[Int].UNSIGNED") + assertEquals(builder("Option[Int]").build(dataType3), "SMALLINT[Option[Int]].UNSIGNED") + assertEquals(builder("Int").build(dataType4), "SMALLINT[Int](1)") + assertEquals(builder("Option[Int]").build(dataType4), "SMALLINT[Option[Int]](1)") + } + + test("MEDIUMINT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.MEDIUMINT(None, true, true) + val dataType2 = DataType.MEDIUMINT(Some(1), false, true) + val dataType3 = DataType.MEDIUMINT(None, true, false) + val dataType4 = DataType.MEDIUMINT(Some(1), false, false) + assertEquals(builder("Int").build(dataType1), "MEDIUMINT[Int].UNSIGNED.ZEROFILL") + assertEquals(builder("Option[Int]").build(dataType1), "MEDIUMINT[Option[Int]].UNSIGNED.ZEROFILL") + assertEquals(builder("Int").build(dataType2), "MEDIUMINT[Int](1).ZEROFILL") + assertEquals(builder("Option[Int]").build(dataType2), "MEDIUMINT[Option[Int]](1).ZEROFILL") + assertEquals(builder("Int").build(dataType3), "MEDIUMINT[Int].UNSIGNED") + assertEquals(builder("Option[Int]").build(dataType3), "MEDIUMINT[Option[Int]].UNSIGNED") + assertEquals(builder("Int").build(dataType4), "MEDIUMINT[Int](1)") + assertEquals(builder("Option[Int]").build(dataType4), "MEDIUMINT[Option[Int]](1)") + } + + test("INT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.INT(None, true, true) + val dataType2 = DataType.INT(Some(1), false, true) + val dataType3 = DataType.INT(None, true, false) + val dataType4 = DataType.INT(Some(1), false, false) + assertEquals(builder("Int").build(dataType1), "INT[Int].UNSIGNED.ZEROFILL") + assertEquals(builder("Option[Int]").build(dataType1), "INT[Option[Int]].UNSIGNED.ZEROFILL") + assertEquals(builder("Int").build(dataType2), "INT[Int](1).ZEROFILL") + assertEquals(builder("Option[Int]").build(dataType2), "INT[Option[Int]](1).ZEROFILL") + assertEquals(builder("Int").build(dataType3), "INT[Int].UNSIGNED") + assertEquals(builder("Option[Int]").build(dataType3), "INT[Option[Int]].UNSIGNED") + assertEquals(builder("Int").build(dataType4), "INT[Int](1)") + assertEquals(builder("Option[Int]").build(dataType4), "INT[Option[Int]](1)") + } + + test("BIGINT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.BIGINT(None, true, true) + val dataType2 = DataType.BIGINT(Some(1), false, true) + val dataType3 = DataType.BIGINT(None, true, false) + val dataType4 = DataType.BIGINT(Some(1), false, false) + assertEquals(builder("BigInt").build(dataType1), "BIGINT[BigInt].UNSIGNED.ZEROFILL") + assertEquals(builder("Option[BigInt]").build(dataType1), "BIGINT[Option[BigInt]].UNSIGNED.ZEROFILL") + assertEquals(builder("BigInt").build(dataType2), "BIGINT[BigInt](1).ZEROFILL") + assertEquals(builder("Option[BigInt]").build(dataType2), "BIGINT[Option[BigInt]](1).ZEROFILL") + assertEquals(builder("BigInt").build(dataType3), "BIGINT[BigInt].UNSIGNED") + assertEquals(builder("Option[BigInt]").build(dataType3), "BIGINT[Option[BigInt]].UNSIGNED") + assertEquals(builder("BigInt").build(dataType4), "BIGINT[BigInt](1)") + } + + test("DECIMAL DataType construction to code string matches the specified string.") { + val dataType1 = DataType.DECIMAL(10, 0, true, true) + val dataType2 = DataType.DECIMAL(10, 0, false, true) + val dataType3 = DataType.DECIMAL(10, 0, true, false) + val dataType4 = DataType.DECIMAL(10, 0, false, false) + assertEquals(builder("BigDecimal").build(dataType1), "DECIMAL[BigDecimal](10, 0).UNSIGNED.ZEROFILL") + assertEquals(builder("Option[BigDecimal]").build(dataType1), "DECIMAL[Option[BigDecimal]](10, 0).UNSIGNED.ZEROFILL") + assertEquals(builder("BigDecimal").build(dataType2), "DECIMAL[BigDecimal](10, 0).ZEROFILL") + assertEquals(builder("Option[BigDecimal]").build(dataType2), "DECIMAL[Option[BigDecimal]](10, 0).ZEROFILL") + assertEquals(builder("BigDecimal").build(dataType3), "DECIMAL[BigDecimal](10, 0).UNSIGNED") + assertEquals(builder("Option[BigDecimal]").build(dataType3), "DECIMAL[Option[BigDecimal]](10, 0).UNSIGNED") + assertEquals(builder("BigDecimal").build(dataType4), "DECIMAL[BigDecimal](10, 0)") + assertEquals(builder("Option[BigDecimal]").build(dataType4), "DECIMAL[Option[BigDecimal]](10, 0)") + } + + test("FLOAT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.FLOAT(10, true, true) + val dataType2 = DataType.FLOAT(10, false, true) + val dataType3 = DataType.FLOAT(10, true, false) + val dataType4 = DataType.FLOAT(10, false, false) + assertEquals(builder("Float").build(dataType1), "FLOAT[Float](10).UNSIGNED.ZEROFILL") + assertEquals(builder("Option[Float]").build(dataType1), "FLOAT[Option[Float]](10).UNSIGNED.ZEROFILL") + assertEquals(builder("Float").build(dataType2), "FLOAT[Float](10).ZEROFILL") + assertEquals(builder("Option[Float]").build(dataType2), "FLOAT[Option[Float]](10).ZEROFILL") + assertEquals(builder("Float").build(dataType3), "FLOAT[Float](10).UNSIGNED") + assertEquals(builder("Option[Float]").build(dataType3), "FLOAT[Option[Float]](10).UNSIGNED") + assertEquals(builder("Float").build(dataType4), "FLOAT[Float](10)") + assertEquals(builder("Option[Float]").build(dataType4), "FLOAT[Option[Float]](10)") + } + + test("CHAR DataType construction to code string matches the specified string.") { + val dataType1 = DataType.CHAR(255, Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.CHAR(255, Some("utf8mb4"), None) + val dataType3 = DataType.CHAR(255, None, Some("utf8mb4_bin")) + val dataType4 = DataType.CHAR(255, None, None) + assertEquals( + builder("String").build(dataType1), + "CHAR[String](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[String]").build(dataType1), + "CHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType2), "CHAR[String](255).CHARACTER_SET(Character.utf8mb4)") + assertEquals( + builder("Option[String]").build(dataType2), + "CHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4)" + ) + assertEquals(builder("String").build(dataType3), "CHAR[String](255).COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("Option[String]").build(dataType3), "CHAR[Option[String]](255).COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("String").build(dataType4), "CHAR[String](255)") + assertEquals(builder("Option[String]").build(dataType4), "CHAR[Option[String]](255)") + } + + test("VARCHAR DataType construction to code string matches the specified string.") { + val dataType1 = DataType.VARCHAR(255, Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.VARCHAR(255, Some("utf8mb4"), None) + val dataType3 = DataType.VARCHAR(255, None, Some("utf8mb4_bin")) + val dataType4 = DataType.VARCHAR(255, None, None) + assertEquals( + builder("String").build(dataType1), + "VARCHAR[String](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[String]").build(dataType1), + "VARCHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType2), "VARCHAR[String](255).CHARACTER_SET(Character.utf8mb4)") + assertEquals( + builder("Option[String]").build(dataType2), + "VARCHAR[Option[String]](255).CHARACTER_SET(Character.utf8mb4)" + ) + assertEquals(builder("String").build(dataType3), "VARCHAR[String](255).COLLATE(Collate.utf8mb4_bin)") + assertEquals( + builder("Option[String]").build(dataType3), + "VARCHAR[Option[String]](255).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType4), "VARCHAR[String](255)") + assertEquals(builder("Option[String]").build(dataType4), "VARCHAR[Option[String]](255)") + } + + test("BINARY DataType construction to code string matches the specified string.") { + val dataType = DataType.BINARY(255) + assertEquals(builder("Array[Byte]").build(dataType), "BINARY[Array[Byte]](255)") + assertEquals(builder("Option[Array[Byte]]").build(dataType), "BINARY[Option[Array[Byte]]](255)") + } + + test("VARBINARY DataType construction to code string matches the specified string.") { + val dataType = DataType.VARBINARY(255) + assertEquals(builder("Array[Byte]").build(dataType), "VARBINARY[Array[Byte]](255)") + assertEquals(builder("Option[Array[Byte]]").build(dataType), "VARBINARY[Option[Array[Byte]]](255)") + } + + test("TINYBLOB DataType construction to code string matches the specified string.") { + val dataType = DataType.TINYBLOB() + assertEquals(builder("Array[Byte]").build(dataType), "TINYBLOB[Array[Byte]]()") + assertEquals(builder("Option[Array[Byte]]").build(dataType), "TINYBLOB[Option[Array[Byte]]]()") + } + + test("TINYTEXT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.TINYTEXT(Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.TINYTEXT(Some("utf8mb4"), None) + val dataType3 = DataType.TINYTEXT(None, Some("utf8mb4_bin")) + val dataType4 = DataType.TINYTEXT(None, None) + assertEquals( + builder("String").build(dataType1), + "TINYTEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[String]").build(dataType1), + "TINYTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType2), "TINYTEXT[String]().CHARACTER_SET(Character.utf8mb4)") + assertEquals( + builder("Option[String]").build(dataType2), + "TINYTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" + ) + assertEquals(builder("String").build(dataType3), "TINYTEXT[String]().COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("Option[String]").build(dataType3), "TINYTEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("String").build(dataType4), "TINYTEXT[String]()") + assertEquals(builder("Option[String]").build(dataType4), "TINYTEXT[Option[String]]()") + } + + test("ENUM DataType construction to code string matches the specified string.") { + val dataType1 = DataType.ENUM(List("Active", "InActive"), Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.ENUM(List("Active", "InActive"), Some("utf8mb4"), None) + val dataType3 = DataType.ENUM(List("Active", "InActive"), None, Some("utf8mb4_bin")) + val dataType4 = DataType.ENUM(List("Active", "InActive"), None, None) + assertEquals( + builder("Status").build(dataType1), + "ENUM[Status](using Status).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[Status]").build(dataType1), + "ENUM[Option[Status]](using Status).CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("Status").build(dataType2), "ENUM[Status](using Status).CHARACTER_SET(Character.utf8mb4)") + assertEquals( + builder("Option[Status]").build(dataType2), + "ENUM[Option[Status]](using Status).CHARACTER_SET(Character.utf8mb4)" + ) + assertEquals(builder("Status").build(dataType3), "ENUM[Status](using Status).COLLATE(Collate.utf8mb4_bin)") + assertEquals( + builder("Option[Status]").build(dataType3), + "ENUM[Option[Status]](using Status).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("Status").build(dataType4), "ENUM[Status](using Status)") + assertEquals(builder("Option[Status]").build(dataType4), "ENUM[Option[Status]](using Status)") + } + + test("BLOB DataType construction to code string matches the specified string.") { + val dataType1 = DataType.BLOB(Some(255)) + val dataType2 = DataType.BLOB(None) + assertEquals(builder("Array[Byte]").build(dataType1), "BLOB[Array[Byte]](255)") + assertEquals(builder("Option[Array[Byte]]").build(dataType1), "BLOB[Option[Array[Byte]]](255)") + assertEquals(builder("Array[Byte]").build(dataType2), "BLOB[Array[Byte]]()") + assertEquals(builder("Option[Array[Byte]]").build(dataType2), "BLOB[Option[Array[Byte]]]()") + } + + test("TEXT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.TEXT(Some(255), Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.TEXT(None, Some("utf8mb4"), None) + val dataType3 = DataType.TEXT(Some(255), None, Some("utf8mb4_bin")) + val dataType4 = DataType.TEXT(None, None, None) + assertEquals( + builder("String").build(dataType1), + "TEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[String]").build(dataType1), + "TEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType2), "TEXT[String]().CHARACTER_SET(Character.utf8mb4)") + assertEquals(builder("Option[String]").build(dataType2), "TEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)") + assertEquals(builder("String").build(dataType3), "TEXT[String]().COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("Option[String]").build(dataType3), "TEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("String").build(dataType4), "TEXT[String]()") + assertEquals(builder("Option[String]").build(dataType4), "TEXT[Option[String]]()") + } + + test("MEDIUMBLOB DataType construction to code string matches the specified string.") { + val dataType = DataType.MEDIUMBLOB() + assertEquals(builder("Array[Byte]").build(dataType), "MEDIUMBLOB[Array[Byte]]()") + assertEquals(builder("Option[Array[Byte]]").build(dataType), "MEDIUMBLOB[Option[Array[Byte]]]()") + } + + test("MEDIUMTEXT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.MEDIUMTEXT(Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.MEDIUMTEXT(Some("utf8mb4"), None) + val dataType3 = DataType.MEDIUMTEXT(None, Some("utf8mb4_bin")) + val dataType4 = DataType.MEDIUMTEXT(None, None) + assertEquals( + builder("String").build(dataType1), + "MEDIUMTEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[String]").build(dataType1), + "MEDIUMTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType2), "MEDIUMTEXT[String]().CHARACTER_SET(Character.utf8mb4)") + assertEquals( + builder("Option[String]").build(dataType2), + "MEDIUMTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" + ) + assertEquals(builder("String").build(dataType3), "MEDIUMTEXT[String]().COLLATE(Collate.utf8mb4_bin)") + assertEquals( + builder("Option[String]").build(dataType3), + "MEDIUMTEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType4), "MEDIUMTEXT[String]()") + assertEquals(builder("Option[String]").build(dataType4), "MEDIUMTEXT[Option[String]]()") + } + + test("LONGBLOB DataType construction to code string matches the specified string.") { + val dataType = DataType.LONGBLOB() + assertEquals(builder("Array[Byte]").build(dataType), "LONGBLOB[Array[Byte]]()") + assertEquals(builder("Option[Array[Byte]]").build(dataType), "LONGBLOB[Option[Array[Byte]]]()") + } + + test("LONGTEXT DataType construction to code string matches the specified string.") { + val dataType1 = DataType.LONGTEXT(Some("utf8mb4"), Some("utf8mb4_bin")) + val dataType2 = DataType.LONGTEXT(Some("utf8mb4"), None) + val dataType3 = DataType.LONGTEXT(None, Some("utf8mb4_bin")) + val dataType4 = DataType.LONGTEXT(None, None) + assertEquals( + builder("String").build(dataType1), + "LONGTEXT[String]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals( + builder("Option[String]").build(dataType1), + "LONGTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4).COLLATE(Collate.utf8mb4_bin)" + ) + assertEquals(builder("String").build(dataType2), "LONGTEXT[String]().CHARACTER_SET(Character.utf8mb4)") + assertEquals( + builder("Option[String]").build(dataType2), + "LONGTEXT[Option[String]]().CHARACTER_SET(Character.utf8mb4)" + ) + assertEquals(builder("String").build(dataType3), "LONGTEXT[String]().COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("Option[String]").build(dataType3), "LONGTEXT[Option[String]]().COLLATE(Collate.utf8mb4_bin)") + assertEquals(builder("String").build(dataType4), "LONGTEXT[String]()") + assertEquals(builder("Option[String]").build(dataType4), "LONGTEXT[Option[String]]()") + } + + test("DATE DataType construction to code string matches the specified string.") { + val dataType = DataType.DATE() + assertEquals(builder("LocalDate").build(dataType), "DATE[LocalDate]") + assertEquals(builder("Option[LocalDate]").build(dataType), "DATE[Option[LocalDate]]") + } + + test("DATETIME DataType construction to code string matches the specified string.") { + val dataType1 = DataType.DATETIME(Some(6)) + val dataType2 = DataType.DATETIME(None) + assertEquals(builder("LocalDateTime").build(dataType1), "DATETIME[LocalDateTime](6)") + assertEquals(builder("Option[LocalDateTime]").build(dataType1), "DATETIME[Option[LocalDateTime]](6)") + assertEquals(builder("LocalDateTime").build(dataType2), "DATETIME[LocalDateTime]") + assertEquals(builder("Option[LocalDateTime]").build(dataType2), "DATETIME[Option[LocalDateTime]]") + } + + test("TIMESTAMP DataType construction to code string matches the specified string.") { + val dataType1 = DataType.TIMESTAMP(Some(6)) + val dataType2 = DataType.TIMESTAMP(None) + assertEquals(builder("LocalDateTime").build(dataType1), "TIMESTAMP[LocalDateTime](6)") + assertEquals(builder("Option[LocalDateTime]").build(dataType1), "TIMESTAMP[Option[LocalDateTime]](6)") + assertEquals(builder("LocalDateTime").build(dataType2), "TIMESTAMP[LocalDateTime]") + assertEquals(builder("Option[LocalDateTime]").build(dataType2), "TIMESTAMP[Option[LocalDateTime]]") + } + + test("TIME DataType construction to code string matches the specified string.") { + val dataType1 = DataType.TIME(Some(6)) + val dataType2 = DataType.TIME(None) + assertEquals(builder("LocalTime").build(dataType1), "TIME[LocalTime](6)") + assertEquals(builder("Option[LocalTime]").build(dataType1), "TIME[Option[LocalTime]](6)") + assertEquals(builder("LocalTime").build(dataType2), "TIME[LocalTime]") + assertEquals(builder("Option[LocalTime]").build(dataType2), "TIME[Option[LocalTime]]") + } + + test("YEAR DataType construction to code string matches the specified string.") { + val dataType1 = DataType.YEAR(Some(4)) + val dataType2 = DataType.YEAR(None) + assertEquals(builder("Year").build(dataType1), "YEAR[Year](4)") + assertEquals(builder("Option[Year]").build(dataType1), "YEAR[Option[Year]](4)") + assertEquals(builder("Year").build(dataType2), "YEAR[Year]") + } + + test("SERIAL DataType construction to code string matches the specified string.") { + val dataType = DataType.SERIAL() + assertEquals(builder("BigInt").build(dataType), "SERIAL[BigInt]") + assertEquals(builder("Option[BigInt]").build(dataType), "SERIAL[BigInt]") } diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/formatter/NamingTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/formatter/NamingTest.scala index b9033127c..891f96c4f 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/formatter/NamingTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/formatter/NamingTest.scala @@ -6,67 +6,66 @@ package ldbc.codegen.formatter -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers +import munit.CatsEffectSuite -class NamingTest extends AnyFlatSpec, Matchers: +class NamingTest extends CatsEffectSuite: - "Naming.toCamel" should "convert COLUMN to column" in { - Naming.toCamel("COLUMN") shouldEqual "column" + test("Naming.toCamel: convert COLUMN to column") { + assertEquals(Naming.toCamel("COLUMN"), "column") } - it should "convert camelCase to camelCase" in { - Naming.toCamel("camelCase") shouldEqual "camelCase" + test("Naming.toCamel: convert camelCase to camelCase") { + assertEquals(Naming.toCamel("camelCase"), "camelCase") } - it should "convert PascalCase to pascalCase" in { - Naming.toCamel("PascalCase") shouldEqual "pascalCase" + test("Naming.toCamel: convert PascalCase to pascalCase") { + assertEquals(Naming.toCamel("PascalCase"), "pascalCase") } - it should "convert snake_case to snakeCase" in { - Naming.toCamel("snake_case") shouldEqual "snakeCase" + test("Naming.toCamel: convert snake_case to snakeCase") { + assertEquals(Naming.toCamel("snake_case"), "snakeCase") } - it should "convert kebab-case to kebabCase" in { - Naming.toCamel("kebab-case") shouldEqual "kebabCase" + test("Naming.toCamel: convert kebab-case to kebabCase") { + assertEquals(Naming.toCamel("kebab-case"), "kebabCase") } - "Naming.toPascal" should "convert COLUMN to Column" in { - Naming.toPascal("COLUMN") shouldEqual "Column" + test("Naming.toPascal: convert COLUMN to Column") { + assertEquals(Naming.toPascal("COLUMN"), "Column") } - it should "convert camelCase to CamelCase" in { - Naming.toPascal("camelCase") shouldEqual "CamelCase" + test("Naming.toPascal: convert camelCase to CamelCase") { + assertEquals(Naming.toPascal("camelCase"), "CamelCase") } - it should "convert PascalCase to PascalCase" in { - Naming.toPascal("PascalCase") shouldEqual "PascalCase" + test("Naming.toPascal: convert PascalCase to PascalCase") { + assertEquals(Naming.toPascal("PascalCase"), "PascalCase") } - it should "convert snake_case to SnakeCase" in { - Naming.toPascal("snake_case") shouldEqual "SnakeCase" + test("Naming.toPascal: convert snake_case to SnakeCase") { + assertEquals(Naming.toPascal("snake_case"), "SnakeCase") } - it should "convert kebab-case to KebabCase" in { - Naming.toPascal("kebab-case") shouldEqual "KebabCase" + test("Naming.toPascal: convert kebab-case to KebabCase") { + assertEquals(Naming.toPascal("kebab-case"), "KebabCase") } - "Naming.toSnake" should "convert COLUMN to column" in { - Naming.toSnake("COLUMN") shouldEqual "column" + test("Naming.toSnake: convert COLUMN to column") { + assertEquals(Naming.toSnake("COLUMN"), "column") } - it should "convert camelCase to camel_case" in { - Naming.toSnake("camelCase") shouldEqual "camel_case" + test("Naming.toSnake: convert camelCase to camel_case") { + assertEquals(Naming.toSnake("camelCase"), "camel_case") } - it should "convert PascalCase to pascal_case" in { - Naming.toSnake("PascalCase") shouldEqual "pascal_case" + test("Naming.toSnake: convert PascalCase to pascal_case") { + assertEquals(Naming.toSnake("PascalCase"), "pascal_case") } - it should "convert snake_case to snake_case" in { - Naming.toSnake("snake_case") shouldEqual "snake_case" + test("Naming.toSnake: convert snake_case to snake_case") { + assertEquals(Naming.toSnake("snake_case"), "snake_case") } - it should "convert kebab-case to kebab_case" in { - Naming.toSnake("kebab-case") shouldEqual "kebab_case" + test("Naming.toSnake: convert kebab-case to kebab_case") { + assertEquals(Naming.toSnake("kebab-case"), "kebab_case") } diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/ColumnParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/ColumnParserTest.scala index e79fd1205..efc3d314a 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/ColumnParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/ColumnParserTest.scala @@ -6,13 +6,13 @@ package ldbc.codegen.parser -import org.scalatest.flatspec.AnyFlatSpec +import munit.CatsEffectSuite -class ColumnParserTest extends AnyFlatSpec, ColumnParser: +class ColumnParserTest extends CatsEffectSuite, ColumnParser: override def fileName: String = "test.sql" - it should "Column parsing test succeeds." in { + test("Column parsing test succeeds.") { assert(parseAll(columnDefinition, "`id` BIGINT(64)").successful) assert(parseAll(columnDefinition, "id BIGINT").successful) assert( @@ -49,7 +49,7 @@ class ColumnParserTest extends AnyFlatSpec, ColumnParser: ) } - it should "Column parsing test fails." in { + test("Column parsing test fails.") { assert(!parseAll(columnDefinition, "Column parsing test fails.").successful) assert(!parseAll(columnDefinition, "`id`").successful) assert(!parseAll(columnDefinition, "'id' BIGINT").successful) diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DataTypeParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DataTypeParserTest.scala index 0b3c0928b..63c5aba75 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DataTypeParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DataTypeParserTest.scala @@ -6,25 +6,25 @@ package ldbc.codegen.parser -import org.scalatest.flatspec.AnyFlatSpec +import munit.CatsEffectSuite -class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: +class DataTypeParserTest extends CatsEffectSuite, DataTypeParser: override def fileName: String = "test.sql" - it should "BIT data type parsing test succeeds." in { + test("BIT data type parsing test succeeds.") { assert(parseAll(bitType, "bit").successful) assert(parseAll(bitType, "Bit(1)").successful) assert(parseAll(bitType, "BIT(64)").successful) } - it should "BIT data type parsing test fails." in { + test("BIT data type parsing test fails.") { assert(!parseAll(bitType, "failed").successful) assert(!parseAll(bitType, "Bit(0)").successful) assert(!parseAll(bitType, "BIT(65)").successful) } - it should "TINYINT data type parsing test succeeds." in { + test("TINYINT data type parsing test succeeds.") { assert(parseAll(tinyintType, "tinyint").successful) assert(parseAll(tinyintType, "Tinyint").successful) assert(parseAll(tinyintType, "Tinyint(1)").successful) @@ -34,7 +34,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(tinyintType, "TINYINT(255) UNSIGNED ZEROFILL").successful) } - it should "TINYINT data type parsing test fails." in { + test("TINYINT data type parsing test fails.") { assert(!parseAll(tinyintType, "failed").successful) assert(!parseAll(tinyintType, "Tinyint(0)").successful) assert(!parseAll(tinyintType, "TINYINT(256)").successful) @@ -42,7 +42,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(tinyintType, "TINYINT(255) ZEROFILL UNSIGNED").successful) } - it should "SMALLINT data type parsing test succeeds." in { + test("SMALLINT data type parsing test succeeds.") { assert(parseAll(smallintType, "smallint").successful) assert(parseAll(smallintType, "Smallint").successful) assert(parseAll(smallintType, "Smallint(1)").successful) @@ -52,7 +52,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(smallintType, "SMALLINT(255) UNSIGNED ZEROFILL").successful) } - it should "SMALLINT data type parsing test fails." in { + test("SMALLINT data type parsing test fails.") { assert(!parseAll(smallintType, "failed").successful) assert(!parseAll(smallintType, "Smallint(0)").successful) assert(!parseAll(smallintType, "SMALLINT(256)").successful) @@ -60,7 +60,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(smallintType, "SMALLINT(255) ZEROFILL UNSIGNED").successful) } - it should "MEDIUMINT data type parsing test succeeds." in { + test("MEDIUMINT data type parsing test succeeds.") { assert(parseAll(mediumintType, "mediumint").successful) assert(parseAll(mediumintType, "Mediumint").successful) assert(parseAll(mediumintType, "Mediumint(1)").successful) @@ -70,7 +70,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(mediumintType, "MEDIUMINT(255) UNSIGNED ZEROFILL").successful) } - it should "MEDIUMINT data type parsing test fails." in { + test("MEDIUMINT data type parsing test fails.") { assert(!parseAll(mediumintType, "failed").successful) assert(!parseAll(mediumintType, "Mediumint(0)").successful) assert(!parseAll(mediumintType, "MEDIUMINT(256)").successful) @@ -78,7 +78,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(mediumintType, "MEDIUMINT(255) ZEROFILL UNSIGNED").successful) } - it should "INT data type parsing test succeeds." in { + test("INT data type parsing test succeeds.") { assert(parseAll(intType, "int").successful) assert(parseAll(intType, "Int(1)").successful) assert(parseAll(intType, "INT(255)").successful) @@ -93,7 +93,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(intType, "INTEGER(255) UNSIGNED ZEROFILL").successful) } - it should "INT data type parsing test fails." in { + test("INT data type parsing test fails.") { assert(!parseAll(intType, "failed").successful) assert(!parseAll(intType, "Int(0)").successful) assert(!parseAll(intType, "INT(256)").successful) @@ -105,7 +105,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(intType, "INTEGER(255) ZEROFILL UNSIGNED").successful) } - it should "BIGINT data type parsing test succeeds." in { + test("BIGINT data type parsing test succeeds.") { assert(parseAll(bigIntType, "bigint").successful) assert(parseAll(bigIntType, "Bigint(1)").successful) assert(parseAll(bigIntType, "BIGINT(255)").successful) @@ -114,7 +114,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(bigIntType, "BIGINT(255) UNSIGNED ZEROFILL").successful) } - it should "BIGINT data type parsing test fails." in { + test("BIGINT data type parsing test fails.") { assert(!parseAll(bigIntType, "failed").successful) assert(!parseAll(bigIntType, "Bigint(0)").successful) assert(!parseAll(bigIntType, "BIGINT(256)").successful) @@ -122,7 +122,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(bigIntType, "BIGINT(255) ZEROFILL UNSIGNED").successful) } - it should "DECIMAL data type parsing test succeeds." in { + test("DECIMAL data type parsing test succeeds.") { assert(parseAll(decimalType, "decimal").successful) assert(parseAll(decimalType, "Decimal(1)").successful) assert(parseAll(decimalType, "DECIMAL(65, 5)").successful) @@ -137,7 +137,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(decimalType, "DEC(65, 30) UNSIGNED ZEROFILL").successful) } - it should "DECIMAL data type parsing test fails." in { + test("DECIMAL data type parsing test fails.") { assert(!parseAll(decimalType, "failed").successful) assert(!parseAll(decimalType, "Decimal(-1)").successful) assert(!parseAll(decimalType, "DECIMAL(66, 0)").successful) @@ -151,7 +151,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(decimalType, "DEC(10, 5) ZEROFILL UNSIGNED").successful) } - it should "FLOAT data type parsing test succeeds." in { + test("FLOAT data type parsing test succeeds.") { assert(parseAll(floatType, "float").successful) assert(parseAll(floatType, "float(0)").successful) assert(parseAll(floatType, "Float(24)").successful) @@ -160,7 +160,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(floatType, "FLOAT(10) UNSIGNED ZEROFILL").successful) } - it should "FLOAT data type parsing test fails." in { + test("FLOAT data type parsing test fails.") { assert(!parseAll(floatType, "failed").successful) assert(!parseAll(floatType, "Float(-1)").successful) assert(!parseAll(floatType, "Float(25)").successful) @@ -168,7 +168,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(floatType, "FLOAT(10) ZEROFILL UNSIGNED").successful) } - it should "DOUBLE data type parsing test succeeds." in { + test("DOUBLE data type parsing test succeeds.") { assert(parseAll(doubleType, "double").successful) assert(parseAll(doubleType, "Double(24, 24)").successful) assert(parseAll(doubleType, "DOUBLE(53, 53)").successful) @@ -183,7 +183,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(doubleType, "REAL UNSIGNED ZEROFILL").successful) } - it should "DOUBLE data type parsing test fails." in { + test("DOUBLE data type parsing test fails.") { assert(!parseAll(doubleType, "failed").successful) assert(!parseAll(doubleType, "double(23, 24)").successful) assert(!parseAll(doubleType, "Double(24, 23)").successful) @@ -197,7 +197,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(doubleType, "REAL ZEROFILL UNSIGNED").successful) } - it should "CHAR data type parsing test succeeds." in { + test("CHAR data type parsing test succeeds.") { assert(parseAll(charType, "char").successful) assert(parseAll(charType, "Char(0)").successful) assert(parseAll(charType, "CHAR(255)").successful) @@ -225,7 +225,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(charType, "NATIONAL CHARACTER CHARACTER SET utf8mb4 COLLATE utf8mb4_bin").successful) } - it should "CHAR data type parsing test fails." in { + test("CHAR data type parsing test fails.") { assert(!parseAll(charType, "failed").successful) assert(!parseAll(charType, "failed Char").successful) assert(!parseAll(charType, "CHAR(-1)").successful) @@ -235,7 +235,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(charType, "CHARACTER(255) CHARACTER SET utf8mb4 COLLATE").successful) } - it should "VARCHAR data type parsing test succeeds." in { + test("VARCHAR data type parsing test succeeds.") { assert(parseAll(varcharType, "Varchar(0)").successful) assert(parseAll(varcharType, "VARCHAR(255)").successful) assert(parseAll(varcharType, "VARCHAR(0) CHARACTER SET utf8mb4").successful) @@ -249,7 +249,7 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(varcharType, "NATIONAL VARCHAR(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin").successful) } - it should "VARCHAR data type parsing test fails." in { + test("VARCHAR data type parsing test fails.") { assert(!parseAll(varcharType, "failed").successful) assert(!parseAll(varcharType, "failed Varchar").successful) assert(!parseAll(varcharType, "NATIONAL VARCHAR").successful) @@ -261,41 +261,41 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(!parseAll(varcharType, "NATIONAL VARCHAR CHARACTER SET utf8mb4 COLLATE utf8mb4_bin").successful) } - it should "BINARY data type parsing test succeeds." in { + test("BINARY data type parsing test succeeds.") { assert(parseAll(binaryType, "binary").successful) assert(parseAll(binaryType, "Binary(0)").successful) assert(parseAll(binaryType, "BINARY(255)").successful) } - it should "BINARY data type parsing test fails." in { + test("BINARY data type parsing test fails.") { assert(!parseAll(binaryType, "failed").successful) assert(!parseAll(binaryType, "binary(-1)").successful) assert(!parseAll(binaryType, "Binary(256)").successful) } - it should "VARBINARY data type parsing test succeeds." in { + test("VARBINARY data type parsing test succeeds.") { assert(parseAll(varbinaryType, "Varbinary(0)").successful) assert(parseAll(varbinaryType, "VARBINARY(255)").successful) } - it should "VARBINARY data type parsing test fails." in { + test("VARBINARY data type parsing test fails.") { assert(!parseAll(varbinaryType, "failed").successful) assert(!parseAll(varbinaryType, "varbinary").successful) assert(!parseAll(varbinaryType, "varbinary(-1)").successful) } - it should "TINYBLOB data type parsing test succeeds." in { + test("TINYBLOB data type parsing test succeeds.") { assert(parseAll(tinyblobType, "tinyblob").successful) assert(parseAll(tinyblobType, "Tinyblob").successful) assert(parseAll(tinyblobType, "TINYBLOB").successful) } - it should "TINYBLOB data type parsing test fails." in { + test("TINYBLOB data type parsing test fails.") { assert(!parseAll(tinyblobType, "failed").successful) assert(!parseAll(tinyblobType, "tinyblob(1)").successful) } - it should "TINYTEXT data type parsing test succeeds." in { + test("TINYTEXT data type parsing test succeeds.") { assert(parseAll(tinytextType, "tinytext").successful) assert(parseAll(tinytextType, "Tinytext").successful) assert(parseAll(tinytextType, "TINYTEXT CHARACTER SET utf8mb4").successful) @@ -308,24 +308,24 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(tinytextType, "TINYTEXT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_bin").successful) } - it should "TINYTEXT data type parsing test fails." in { + test("TINYTEXT data type parsing test fails.") { assert(!parseAll(tinytextType, "failed").successful) assert(!parseAll(tinytextType, "Tinytext(-1)").successful) assert(!parseAll(tinytextType, "TINYTEXT CHARACTER utf8mb4").successful) } - it should "BLOB data type parsing test succeeds." in { + test("BLOB data type parsing test succeeds.") { assert(parseAll(blobType, "blob").successful) assert(parseAll(blobType, "Blob(0)").successful) assert(parseAll(blobType, "BLOB(255)").successful) } - it should "BLOB data type parsing test fails." in { + test("BLOB data type parsing test fails.") { assert(!parseAll(blobType, "failed").successful) assert(!parseAll(blobType, "Blob(-1)").successful) } - it should "TEXT data type parsing test succeeds." in { + test("TEXT data type parsing test succeeds.") { assert(parseAll(textType, "text").successful) assert(parseAll(textType, "Text(0)").successful) assert(parseAll(textType, "TEXT(255)").successful) @@ -339,25 +339,25 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(textType, "TEXT(255) CHARACTER SET=utf8mb4 COLLATE=utf8mb4_bin").successful) } - it should "TEXT data type parsing test fails." in { + test("TEXT data type parsing test fails.") { assert(!parseAll(textType, "failed").successful) assert(!parseAll(textType, "text(-1)").successful) assert(!parseAll(textType, "Text(256)").successful) assert(!parseAll(textType, "TEXT(0) CHARACTER utf8mb4").successful) } - it should "MEDIUMBLOB data type parsing test succeeds." in { + test("MEDIUMBLOB data type parsing test succeeds.") { assert(parseAll(mediumblobType, "mediumblob").successful) assert(parseAll(mediumblobType, "Mediumblob").successful) assert(parseAll(mediumblobType, "MEDIUMBLOB").successful) } - it should "MEDIUMBLOB data type parsing test fails." in { + test("MEDIUMBLOB data type parsing test fails.") { assert(!parseAll(mediumblobType, "failed").successful) assert(!parseAll(mediumblobType, "mediumblob(1)").successful) } - it should "MEDIUMTEXT data type parsing test succeeds." in { + test("MEDIUMTEXT data type parsing test succeeds.") { assert(parseAll(mediumtextType, "mediumtext").successful) assert(parseAll(mediumtextType, "Mediumtext").successful) assert(parseAll(mediumtextType, "MEDIUMTEXT CHARACTER SET utf8mb4").successful) @@ -370,24 +370,24 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(mediumtextType, "MEDIUMTEXT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_bin").successful) } - it should "MEDIUMTEXT data type parsing test fails." in { + test("MEDIUMTEXT data type parsing test fails.") { assert(!parseAll(mediumtextType, "failed").successful) assert(!parseAll(mediumtextType, "mediumtext(-1)").successful) assert(!parseAll(mediumtextType, "MEDIUMTEXT CHARACTER utf8mb4").successful) } - it should "LONGBLOB data type parsing test succeeds." in { + test("LONGBLOB data type parsing test succeeds.") { assert(parseAll(longblobType, "longblob").successful) assert(parseAll(longblobType, "Longblob").successful) assert(parseAll(longblobType, "LONGBLOB").successful) } - it should "LONGBLOB data type parsing test fails." in { + test("LONGBLOB data type parsing test fails.") { assert(!parseAll(longblobType, "failed").successful) assert(!parseAll(longblobType, "longblob(1)").successful) } - it should "LONGTEXT data type parsing test succeeds." in { + test("LONGTEXT data type parsing test succeeds.") { assert(parseAll(longtextType, "longtext").successful) assert(parseAll(longtextType, "Longtext").successful) assert(parseAll(longtextType, "LONGTEXT CHARACTER SET utf8mb4").successful) @@ -400,96 +400,96 @@ class DataTypeParserTest extends AnyFlatSpec, DataTypeParser: assert(parseAll(longtextType, "LONGTEXT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_bin").successful) } - it should "LONGTEXT data type parsing test fails." in { + test("LONGTEXT data type parsing test fails.") { assert(!parseAll(longtextType, "failed").successful) assert(!parseAll(longtextType, "longtext(-1)").successful) assert(!parseAll(longtextType, "LONGTEXT CHARACTER utf8mb4").successful) } - it should "ENUM data type parsing test succeeds." in { + test("ENUM data type parsing test succeeds.") { assert(parseAll(enumType, "ENUM('Active', 'InActive')").successful) assert(parseAll(enumType, "ENUM('Active')").successful) } - it should "ENUM data type parsing test fails." in { + test("ENUM data type parsing test fails.") { assert(!parseAll(enumType, "failed").successful) assert(!parseAll(enumType, "ENUM").successful) assert(!parseAll(enumType, "ENUM()").successful) assert(!parseAll(enumType, "ENUM(Active)").successful) } - it should "DATE data type parsing test succeeds." in { + test("DATE data type parsing test succeeds.") { assert(parseAll(dateType, "date").successful) assert(parseAll(dateType, "Date").successful) assert(parseAll(dateType, "DATE").successful) } - it should "DATE data type parsing test fails." in { + test("DATE data type parsing test fails.") { assert(!parseAll(dateType, "failed").successful) assert(!parseAll(dateType, "DATE(1)").successful) } - it should "DATETIME data type parsing test succeeds." in { + test("DATETIME data type parsing test succeeds.") { assert(parseAll(datetimeType, "datetime").successful) assert(parseAll(datetimeType, "Datetime(0)").successful) assert(parseAll(datetimeType, "DATETIME(6)").successful) } - it should "DATETIME data type parsing test fails." in { + test("DATETIME data type parsing test fails.") { assert(!parseAll(datetimeType, "failed").successful) assert(!parseAll(datetimeType, "Datetime(-1)").successful) assert(!parseAll(datetimeType, "DATETIME(7)").successful) } - it should "TIMESTAMP data type parsing test succeeds." in { + test("TIMESTAMP data type parsing test succeeds.") { assert(parseAll(timestampType, "timestamp").successful) assert(parseAll(timestampType, "Timestamp(0)").successful) assert(parseAll(timestampType, "TIMESTAMP(6)").successful) } - it should "TIMESTAMP data type parsing test fails." in { + test("TIMESTAMP data type parsing test fails.") { assert(!parseAll(timestampType, "failed").successful) assert(!parseAll(timestampType, "Timestamp(-1)").successful) assert(!parseAll(timestampType, "TIMESTAMP(7)").successful) } - it should "TIME data type parsing test succeeds." in { + test("TIME data type parsing test succeeds.") { assert(parseAll(timeType, "time").successful) assert(parseAll(timeType, "Time(0)").successful) assert(parseAll(timeType, "TIME(6)").successful) } - it should "TIME data type parsing test fails." in { + test("TIME data type parsing test fails.") { assert(!parseAll(timeType, "failed").successful) assert(!parseAll(timeType, "Time(-1)").successful) assert(!parseAll(timeType, "TIME(7)").successful) } - it should "YEAR data type parsing test succeeds." in { + test("YEAR data type parsing test succeeds.") { assert(parseAll(yearType, "year").successful) assert(parseAll(yearType, "YEAR(4)").successful) } - it should "YEAR data type parsing test fails." in { + test("YEAR data type parsing test fails.") { assert(!parseAll(yearType, "failed").successful) assert(!parseAll(yearType, "YEAR(0)").successful) } - it should "SERIAL data type parsing test succeeds." in { + test("SERIAL data type parsing test succeeds.") { assert(parseAll(serialType, "SERIAL").successful) } - it should "SERIAL data type parsing test fails." in { + test("SERIAL data type parsing test fails.") { assert(!parseAll(serialType, "failed").successful) assert(!parseAll(serialType, "SERIAL(0)").successful) } - it should "BOOLEAN data type parsing test succeeds." in { + test("BOOLEAN data type parsing test succeeds.") { assert(parseAll(booleanType, "boolean").successful) assert(parseAll(booleanType, "bool").successful) } - it should "BOOLEAN data type parsing test fails." in { + test("BOOLEAN data type parsing test fails.") { assert(!parseAll(booleanType, "failed").successful) assert(!parseAll(booleanType, "tinyint(1)").successful) } diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DatabaseStatementParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DatabaseStatementParserTest.scala index 57e2ac152..99964401a 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DatabaseStatementParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/DatabaseStatementParserTest.scala @@ -6,13 +6,13 @@ package ldbc.codegen.parser -import org.scalatest.flatspec.AnyFlatSpec +import munit.CatsEffectSuite -class DatabaseStatementParserTest extends AnyFlatSpec, DatabaseStatementParser: +class DatabaseStatementParserTest extends CatsEffectSuite, DatabaseStatementParser: override def fileName: String = "test.sql" - it should "Database create statement parsing test succeeds." in { + test("Database create statement parsing test succeeds.") { assert(parseAll(databaseStatements, "CREATE DATABASE `database`;").successful) assert(parseAll(databaseStatements, "CREATE DATABASE `database` DEFAULT CHARACTER SET utf8mb4;").successful) assert(parseAll(databaseStatements, "CREATE DATABASE `database` COLLATE utf8mb4_bin;").successful) @@ -50,7 +50,7 @@ class DatabaseStatementParserTest extends AnyFlatSpec, DatabaseStatementParser: ) } - it should "Database create statement parsing test fails." in { + test("Database create statement parsing test fails.") { assert(!parseAll(databaseStatements, "CREATE DATABASE;").successful) assert(!parseAll(databaseStatements, "CREATE DATABASE /* comment */;").successful) assert(!parseAll(databaseStatements, "CREATE DATABASE `database` ENCRYPTION X;").successful) @@ -59,7 +59,7 @@ class DatabaseStatementParserTest extends AnyFlatSpec, DatabaseStatementParser: assert(!parseAll(databaseStatements, "CREATE SCHEMA `database` ENCRYPTION X;").successful) } - it should "Database drop statement parsing test succeeds." in { + test("Database drop statement parsing test succeeds.") { assert(parseAll(databaseStatements, "DROP DATABASE `database`;").successful) assert(parseAll(databaseStatements, "DROP DATABASE IF EXISTS `database`;").successful) assert(parseAll(databaseStatements, "DROP DATABASE IF NOT EXISTS `database`;").successful) @@ -71,19 +71,19 @@ class DatabaseStatementParserTest extends AnyFlatSpec, DatabaseStatementParser: assert(parseAll(databaseStatements, "/* comment */ DROP /* comment */ SCHEMA /* comment */ `database`;").successful) } - it should "Database drop statement parsing test fails." in { + test("Database drop statement parsing test fails.") { assert(!parseAll(databaseStatements, "DROP DATABASE;").successful) assert(!parseAll(databaseStatements, "/* comment */ DROP /* comment */;").successful) assert(!parseAll(databaseStatements, "DROP SCHEMA;").successful) assert(!parseAll(databaseStatements, "/* comment */ DROP /* comment */;").successful) } - it should "Database use statement parsing test succeeds." in { + test("Database use statement parsing test succeeds.") { assert(parseAll(databaseStatements, "USE `database`;").successful) assert(parseAll(databaseStatements, "/* comment */ USE /* comment */ `database`;").successful) } - it should "Database use statement parsing test fails." in { + test("Database use statement parsing test fails.") { assert(!parseAll(databaseStatements, "USE;").successful) assert(!parseAll(databaseStatements, "/* comment */ USE /* comment */;").successful) } diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/KeyParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/KeyParserTest.scala index 706e08940..4a619f8b9 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/KeyParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/KeyParserTest.scala @@ -6,13 +6,13 @@ package ldbc.codegen.parser -import org.scalatest.flatspec.AnyFlatSpec +import munit.CatsEffectSuite -class KeyParserTest extends AnyFlatSpec, KeyParser: +class KeyParserTest extends CatsEffectSuite, KeyParser: override def fileName: String = "test.sql" - it should "Key definitions parsing test succeeds." in { + test("Key definitions parsing test succeeds.") { assert(parseAll(keyDefinitions, "INDEX (`column`)").successful) assert(parseAll(keyDefinitions, "KEY (`column`)").successful) assert(parseAll(keyDefinitions, "INDEX `index` (`column1`, `column2`)").successful) @@ -53,7 +53,7 @@ class KeyParserTest extends AnyFlatSpec, KeyParser: ) } - it should "Key definitions parsing test fails." in { + test("Key definitions parsing test fails.") { assert(!parseAll(keyDefinitions, "failed").successful) assert(!parseAll(keyDefinitions, "INDEX USING failed (`column`)").successful) assert(!parseAll(keyDefinitions, "INDEX (`column` failed)").successful) diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/SetParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/SetParserTest.scala index b32f3437d..babf13888 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/SetParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/SetParserTest.scala @@ -6,13 +6,13 @@ package ldbc.codegen.parser -import org.scalatest.flatspec.AnyFlatSpec +import munit.CatsEffectSuite -class SetParserTest extends AnyFlatSpec, SetParser: +class SetParserTest extends CatsEffectSuite, SetParser: override def fileName: String = "test.sql" - it should "SET statement parsing test succeeds." in { + test("SET statement parsing test succeeds.") { assert( parseAll( setStatements, diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/TableParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/TableParserTest.scala index 8eb9266a5..7ff411919 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/TableParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/TableParserTest.scala @@ -6,13 +6,13 @@ package ldbc.codegen.parser -import org.scalatest.flatspec.AnyFlatSpec +import munit.CatsEffectSuite -class TableParserTest extends AnyFlatSpec, TableParser: +class TableParserTest extends CatsEffectSuite, TableParser: override def fileName: String = "test.sql" - it should "Table create statement parsing test succeeds." in { + test("Table create statement parsing test succeeds.") { assert( parseAll( createTableStatement, @@ -240,7 +240,7 @@ class TableParserTest extends AnyFlatSpec, TableParser: ) } - it should "Table create statement parsing test fails." in { + test("Table create statement parsing test fails.") { assert( !parseAll( createTableStatement, @@ -450,7 +450,7 @@ class TableParserTest extends AnyFlatSpec, TableParser: ) } - it should "Table drop statement parsing test succeeds." in { + test("Table drop statement parsing test succeeds.") { assert(parseAll(dropTableStatement, "DROP TABLE IF NOT EXISTS `table`;").successful) assert(parseAll(dropTableStatement, "DROP TABLE IF EXISTS `table`;").successful) assert(parseAll(dropTableStatement, "DROP TABLE `table`;").successful) @@ -465,7 +465,7 @@ class TableParserTest extends AnyFlatSpec, TableParser: ) } - it should "Table drop statement parsing test fails" in { + test("Table drop statement parsing test fails") { assert(!parseAll(dropTableStatement, "DROP `table`;").successful) assert(!parseAll(dropTableStatement, "DROP IF EXISTS;").successful) assert(!parseAll(dropTableStatement, "DROP IF NOT EXISTS;").successful) diff --git a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/yml/ParserTest.scala b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/yml/ParserTest.scala index 0817a0986..ddcee5373 100644 --- a/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/yml/ParserTest.scala +++ b/module/ldbc-codegen/shared/src/test/scala/ldbc/codegen/parser/yml/ParserTest.scala @@ -6,96 +6,93 @@ package ldbc.codegen.parser.yml -import org.specs2.mutable.Specification +import munit.CatsEffectSuite -object ParserTest extends Specification: +class ParserTest extends CatsEffectSuite: - "Testing the Custom" should { - - "The model generated from the Yaml string matches the specified model." in { - val parser = Parser( - Parser.Database( - "test", - Seq( - Parser.Table( - "test", - Some(Seq(Parser.Column("id", "Long"))), - Some(Parser.Extend(Seq("ldbc.custom.extend"))), - Some(Parser.Extend(Seq("ldbc.custom.extend"))) - ) + test("The model generated from the Yaml string matches the specified model.") { + val parser = Parser( + Parser.Database( + "test", + Seq( + Parser.Table( + "test", + Some(Seq(Parser.Column("id", "Long"))), + Some(Parser.Extend(Seq("ldbc.custom.extend"))), + Some(Parser.Extend(Seq("ldbc.custom.extend"))) ) ) ) - val parsed = Parser.parse(""" - |database: - | name: 'test' - | tables: - | - name: 'test' - | columns: - | - name: 'id' - | type: 'Long' - | object: - | extends: - | - ldbc.custom.extend - | class: - | extends: - | - ldbc.custom.extend - |""".stripMargin) - parsed === parser - } + ) + val parsed = Parser.parse(""" + |database: + | name: 'test' + | tables: + | - name: 'test' + | columns: + | - name: 'id' + | type: 'Long' + | object: + | extends: + | - ldbc.custom.extend + | class: + | extends: + | - ldbc.custom.extend + |""".stripMargin) + assertEquals(parsed, parser) + } - "The model generated from the Yaml string matches the specified model." in { - val parser = Parser( - Parser.Database( - "test", - Seq( - Parser.Table( - "test", - Some(Seq(Parser.Column("id", "Long"))), - None, - None - ) + test("The model generated from the Yaml string matches the specified model.") { + val parser = Parser( + Parser.Database( + "test", + Seq( + Parser.Table( + "test", + Some(Seq(Parser.Column("id", "Long"))), + None, + None ) ) ) - val parsed = Parser.parse(""" - |database: - | name: 'test' - | tables: - | - name: 'test' - | columns: - | - name: 'id' - | type: 'Long' - |""".stripMargin) - parsed === parser - } + ) + val parsed = Parser.parse(""" + |database: + | name: 'test' + | tables: + | - name: 'test' + | columns: + | - name: 'id' + | type: 'Long' + |""".stripMargin) + assertEquals(parsed, parser) + } - "The model generated from the Yaml string matches the specified model." in { - val parser = Parser( - Parser.Database( - "test", - Seq( - Parser.Table( - "test", - None, - Some(Parser.Extend(Seq("ldbc.custom.extend"))), - Some(Parser.Extend(Seq("ldbc.custom.extend"))) - ) + test("The model generated from the Yaml string matches the specified model.") { + val parser = Parser( + Parser.Database( + "test", + Seq( + Parser.Table( + "test", + None, + Some(Parser.Extend(Seq("ldbc.custom.extend"))), + Some(Parser.Extend(Seq("ldbc.custom.extend"))) ) ) ) - val parsed = Parser.parse(""" - |database: - | name: 'test' - | tables: - | - name: 'test' - | object: - | extends: - | - ldbc.custom.extend - | class: - | extends: - | - ldbc.custom.extend - |""".stripMargin) - parsed === parser - } + ) + val parsed = Parser.parse(""" + |database: + | name: 'test' + | tables: + | - name: 'test' + | object: + | extends: + | - ldbc.custom.extend + | class: + | extends: + | - ldbc.custom.extend + |""".stripMargin) + assertEquals(parsed, parser) }