Skip to content

Commit

Permalink
RunMigrationsTest: extract duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-koscejev committed Oct 26, 2023
1 parent 183ea36 commit 1d81a90
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/test/kotlin/test/de/itemis/mps/gradle/RunMigrationsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ class RunMigrationsTest {
""".trimIndent()
)

val result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
val result = gradleRunner()
.withArguments("runMigrations")
.withPluginClasspath()
.build()
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":runMigrations")?.outcome)
}
Expand All @@ -96,10 +94,8 @@ class RunMigrationsTest {
""".trimIndent()
)

val result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
val result = gradleRunner()
.withArguments("runMigrations")
.withPluginClasspath()
.buildAndFail()

assertThat(result.output, containsString("The force migration flag is only supported for MPS version 2021.3.0 and higher."))
Expand All @@ -124,10 +120,8 @@ class RunMigrationsTest {
""".trimIndent()
)

val result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
val result = gradleRunner()
.withArguments("runMigrations")
.withPluginClasspath()
.build()

Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":runMigrations")?.outcome)
Expand All @@ -150,10 +144,8 @@ class RunMigrationsTest {
""".trimIndent()
)

val result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
val result = gradleRunner()
.withArguments("runMigrations")
.withPluginClasspath()
.buildAndFail()

assertThat(result.output, containsString("The path to the project doesn't exist:"))
Expand All @@ -173,12 +165,14 @@ class RunMigrationsTest {
""".trimIndent()
)

val result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
val result = gradleRunner()
.withArguments("runMigrations")
.withPluginClasspath()
.buildAndFail()

assertThat(result.output, containsString("Specified MPS location does not exist or is not a directory:"))
}
}

private fun gradleRunner(): GradleRunner = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withPluginClasspath()
}

0 comments on commit 1d81a90

Please sign in to comment.