From 33635715e6311427947af24b30c91e5ac2a584e0 Mon Sep 17 00:00:00 2001 From: Karol Chmist Date: Thu, 23 Apr 2020 09:47:34 +0200 Subject: [PATCH] Fix CommandsTests for scala 2.13 Scala 2.12 and 2.13 give different outputs for toString --- .../UnitTests/CommandTestsPreview.scala | 73 +++++++++++++++++++ .../UnitTests/CommandTestsPreview.scala | 73 +++++++++++++++++++ .../test/scala/UnitTests/CommandsTests.scala | 69 +----------------- 3 files changed, 149 insertions(+), 66 deletions(-) create mode 100644 migrations/slick/src/test/scala-2.12/UnitTests/CommandTestsPreview.scala create mode 100644 migrations/slick/src/test/scala-2.13/UnitTests/CommandTestsPreview.scala diff --git a/migrations/slick/src/test/scala-2.12/UnitTests/CommandTestsPreview.scala b/migrations/slick/src/test/scala-2.12/UnitTests/CommandTestsPreview.scala new file mode 100644 index 0000000..01b9d71 --- /dev/null +++ b/migrations/slick/src/test/scala-2.12/UnitTests/CommandTestsPreview.scala @@ -0,0 +1,73 @@ +package com.liyaos.forklift.slick.tests.unittests + +object CommandTestsPreview { + + val CommandTests_PreviewSeq: Seq[String] = List( + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +1 SqlMigration: +${"\t"}[create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR(255) NOT NULL,"last" VARCHAR(255) NOT NULL)] + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +2 DBIOMigration: +${"\t"}CommandTests.profile.api.queryInsertActionExtensionMethods[CommandTests.this.UsersV2#TableElementType, Seq](CommandTests.UsersV2).++=(scala.collection.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) + +-------------------------------------------------------------------------------- +""") + + val CommandTests_PreviewSeq_MySql = List( + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +1 SqlMigration: +${"\t"}[create table `users` (`id` INTEGER NOT NULL PRIMARY KEY,`first` VARCHAR(255) NOT NULL,`last` VARCHAR(255) NOT NULL)] + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +2 DBIOMigration: +${"\t"}MySQLCommandTests.profile.api.queryInsertActionExtensionMethods[MySQLCommandTests.this.UsersV2#TableElementType, Seq](MySQLCommandTests.UsersV2).++=(scala.collection.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) + +-------------------------------------------------------------------------------- +""") + + val CommandTests_PreviewSeq_Derby = List( + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +1 SqlMigration: +${"\t"}[create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR(255) NOT NULL,"last" VARCHAR(255) NOT NULL)] + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +2 DBIOMigration: +${"\t"}DerbyCommandTests.profile.api.queryInsertActionExtensionMethods[DerbyCommandTests.this.UsersV2#TableElementType, Seq](DerbyCommandTests.UsersV2).++=(scala.collection.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) + +-------------------------------------------------------------------------------- +""") +} diff --git a/migrations/slick/src/test/scala-2.13/UnitTests/CommandTestsPreview.scala b/migrations/slick/src/test/scala-2.13/UnitTests/CommandTestsPreview.scala new file mode 100644 index 0000000..a2480ef --- /dev/null +++ b/migrations/slick/src/test/scala-2.13/UnitTests/CommandTestsPreview.scala @@ -0,0 +1,73 @@ +package com.liyaos.forklift.slick.tests.unittests + +object CommandTestsPreview { + + val CommandTests_PreviewSeq: Seq[String] = List( + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +1 SqlMigration: +${"\t"}[create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR(255) NOT NULL,"last" VARCHAR(255) NOT NULL)] + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +2 DBIOMigration: +${"\t"}CommandTests.profile.api.queryInsertActionExtensionMethods[CommandTests.this.UsersV2#TableElementType, [+A]Seq[A]](CommandTests.UsersV2).++=(scala.collection.immutable.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) + +-------------------------------------------------------------------------------- +""") + + val CommandTests_PreviewSeq_MySql = List( + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +1 SqlMigration: +${"\t"}[create table `users` (`id` INTEGER NOT NULL PRIMARY KEY,`first` VARCHAR(255) NOT NULL,`last` VARCHAR(255) NOT NULL)] + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +2 DBIOMigration: +${"\t"}MySQLCommandTests.profile.api.queryInsertActionExtensionMethods[MySQLCommandTests.this.UsersV2#TableElementType, [+A]Seq[A]](MySQLCommandTests.UsersV2).++=(scala.collection.immutable.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) + +-------------------------------------------------------------------------------- +""") + + val CommandTests_PreviewSeq_Derby = List( + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +1 SqlMigration: +${"\t"}[create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR(255) NOT NULL,"last" VARCHAR(255) NOT NULL)] + +-------------------------------------------------------------------------------- +""", + s"""-------------------------------------------------------------------------------- +NOT YET APPLIED MIGRATIONS PREVIEW: + +2 DBIOMigration: +${"\t"}DerbyCommandTests.profile.api.queryInsertActionExtensionMethods[DerbyCommandTests.this.UsersV2#TableElementType, [+A]Seq[A]](DerbyCommandTests.UsersV2).++=(scala.collection.immutable.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) + +-------------------------------------------------------------------------------- +""") +} diff --git a/migrations/slick/src/test/scala/UnitTests/CommandsTests.scala b/migrations/slick/src/test/scala/UnitTests/CommandsTests.scala index 8db8467..9051313 100644 --- a/migrations/slick/src/test/scala/UnitTests/CommandsTests.scala +++ b/migrations/slick/src/test/scala/UnitTests/CommandsTests.scala @@ -42,28 +42,7 @@ trait CommandTests extends FlatSpec { ))) } - val PreviewSeq: Seq[String] = List( -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - --------------------------------------------------------------------------------- -""", -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - -1 SqlMigration: -${"\t"}[create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR(255) NOT NULL,"last" VARCHAR(255) NOT NULL)] - --------------------------------------------------------------------------------- -""", -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - -2 DBIOMigration: -${"\t"}CommandTests.profile.api.queryInsertActionExtensionMethods[CommandTests.this.UsersV2#TableElementType, Seq](CommandTests.UsersV2).++=(scala.collection.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) - --------------------------------------------------------------------------------- -""") + val PreviewSeq: Seq[String] = CommandTestsPreview.CommandTests_PreviewSeq "initOp" should "create migration tables" in { val m = new SlickMigrationManager @@ -255,28 +234,7 @@ class MySQLCommandTests extends CommandTests with MySQLConfigFile { ))) } - override val PreviewSeq: Seq[String] = List( -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - --------------------------------------------------------------------------------- -""", -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - -1 SqlMigration: -${"\t"}[create table `users` (`id` INTEGER NOT NULL PRIMARY KEY,`first` VARCHAR(255) NOT NULL,`last` VARCHAR(255) NOT NULL)] - --------------------------------------------------------------------------------- -""", -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - -2 DBIOMigration: -${"\t"}MySQLCommandTests.profile.api.queryInsertActionExtensionMethods[MySQLCommandTests.this.UsersV2#TableElementType, Seq](MySQLCommandTests.UsersV2).++=(scala.collection.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) - --------------------------------------------------------------------------------- -""") + override val PreviewSeq: Seq[String] = CommandTestsPreview.CommandTests_PreviewSeq_MySql } class PostgresCommandTests extends CommandTests with PostgresConfigFile @@ -300,26 +258,5 @@ class DerbyCommandTests extends CommandTests with DerbyConfigFile { ))) } - override val PreviewSeq: Seq[String] = List( -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - --------------------------------------------------------------------------------- -""", -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - -1 SqlMigration: -${"\t"}[create table "users" ("id" INTEGER NOT NULL PRIMARY KEY,"first" VARCHAR(255) NOT NULL,"last" VARCHAR(255) NOT NULL)] - --------------------------------------------------------------------------------- -""", -s"""-------------------------------------------------------------------------------- -NOT YET APPLIED MIGRATIONS PREVIEW: - -2 DBIOMigration: -${"\t"}DerbyCommandTests.profile.api.queryInsertActionExtensionMethods[DerbyCommandTests.this.UsersV2#TableElementType, Seq](DerbyCommandTests.UsersV2).++=(scala.collection.Seq[com.liyaos.forklift.slick.tests.unittests.UsersRow](UsersRow(1, "Chris", "Vogt"), UsersRow(2, "Yao", "Li"))) - --------------------------------------------------------------------------------- -""") + override val PreviewSeq: Seq[String] = CommandTestsPreview.CommandTests_PreviewSeq_Derby }