Skip to content

Commit

Permalink
Fix kotests
Browse files Browse the repository at this point in the history
  • Loading branch information
Narmada M committed Feb 6, 2023
1 parent 3980fd3 commit 356859e
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ import org.gradle.testfixtures.ProjectBuilder


internal class OpenApiMergerGradlePluginTest: WordSpec({
val project = ProjectBuilder.builder().build()

val builder = ProjectBuilder.builder()

"Using the Plugin ID" should {
"Apply the Plugin" {
val project = builder.build()
project.pluginManager.apply("com.rameshkp.openapi-merger-gradle-plugin")
project.plugins.getPlugin(OpenApiMergerGradlePlugin::class.java) shouldNotBe null
}
}

"Applying the Plugin" should {
val project = builder.build()
project.pluginManager.apply(OpenApiMergerGradlePlugin::class.java)

"Register an extension with name 'openApiMerger'" {
Expand All @@ -38,6 +39,7 @@ internal class OpenApiMergerGradlePluginTest: WordSpec({
}

"Running the 'openApiMerger' task" should {
val project = builder.build()
project.pluginManager.apply(OpenApiMergerGradlePlugin::class.java)
val openApiMergerExtension = project.extensions.getByName("openApiMerger") as OpenApiMergerExtension
val openApiMerger = project.tasks.getByName("mergeOpenApiFiles") as OpenApiMergerTask
Expand Down Expand Up @@ -78,16 +80,26 @@ internal class OpenApiMergerGradlePluginTest: WordSpec({
OpenApi Info Version cannot be blank
""".trimIndent()
}
"Throw exception when output file extension is invalid" {
}

"Running the 'openApiMerger' task with invalid file extension" should {
"Throw exception" {
val project = builder.build()
project.pluginManager.apply(OpenApiMergerGradlePlugin::class.java)
val openApiMergerExtension = project.extensions.getByName("openApiMerger") as OpenApiMergerExtension
openApiMergerExtension.inputDirectory.set(project.buildDir)

openApiMergerExtension.openApi.openApiVersion.set("3.0.3")
openApiMergerExtension.openApi.info.title.set("Title")
openApiMergerExtension.openApi.info.version.set("version")
openApiMergerExtension.output.fileExtension.set("txt")

val exception = shouldThrow<GradleException> {
val openApiMerger = project.tasks.getByName("mergeOpenApiFiles") as OpenApiMergerTask
openApiMerger.execute()
}
exception.message shouldBe "Invalid file extension txt. Valid values are [yaml, json, yml]"
exception.message shouldBe "Could not create task ':mergeOpenApiFiles'."
}
}

})
})

0 comments on commit 356859e

Please sign in to comment.