Install and use kotest
This commit is contained in:
@@ -75,6 +75,8 @@ dependencies {
|
|||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.7.20")
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.7.20")
|
||||||
testImplementation("org.amshove.kluent:kluent:1.68")
|
testImplementation("org.amshove.kluent:kluent:1.68")
|
||||||
|
testImplementation("io.kotest:kotest-runner-junit5:5.5.5")
|
||||||
|
testImplementation("io.kotest:kotest-property:5.5.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesJar by tasks.creating(Jar::class) {
|
val sourcesJar by tasks.creating(Jar::class) {
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package fr.postgresjson.functionGenerator
|
package fr.postgresjson.functionGenerator
|
||||||
|
|
||||||
import fr.postgresjson.definition.Function
|
import fr.postgresjson.definition.Function
|
||||||
import kotlin.test.assertEquals
|
import io.kotest.core.spec.style.StringSpec
|
||||||
import org.junit.jupiter.api.Test
|
import org.amshove.kluent.`should be equal to`
|
||||||
|
|
||||||
class FunctionGeneratorTest {
|
class FunctionGeneratorTest : StringSpec({
|
||||||
private val functionDirectory = this::class.java.getResource("/sql/function/Test")!!.toURI()
|
val functionDirectory = this::class.java.getResource("/sql/function/Test")!!.toURI()
|
||||||
private val generator = FunctionGenerator(functionDirectory)
|
val generator = FunctionGenerator(functionDirectory)
|
||||||
|
|
||||||
@Test
|
"generate function with input object and output object" {
|
||||||
fun `generate function`() {
|
|
||||||
val functionSql = """
|
val functionSql = """
|
||||||
|create or replace function test_function_object (inout resource json)
|
|create or replace function test_function_object (inout resource json)
|
||||||
|language plpgsql
|
|language plpgsql
|
||||||
@@ -34,13 +33,10 @@ class FunctionGeneratorTest {
|
|||||||
|}
|
|}
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
|
|
||||||
val generated: String = generator.generate(Function(functionSql))
|
generator.generate(Function(functionSql)) `should be equal to` expectedGenerated
|
||||||
|
|
||||||
assertEquals(expectedGenerated, generated)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
"generate function with return void" {
|
||||||
fun `generate function with return void`() {
|
|
||||||
val functionSql = """
|
val functionSql = """
|
||||||
|create or replace function test_function_void (name text default 'plop') returns void
|
|create or replace function test_function_void (name text default 'plop') returns void
|
||||||
|language plpgsql
|
|language plpgsql
|
||||||
@@ -63,13 +59,10 @@ class FunctionGeneratorTest {
|
|||||||
|}
|
|}
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
|
|
||||||
val generated: String = generator.generate(Function(functionSql))
|
generator.generate(Function(functionSql)) `should be equal to` expectedGenerated
|
||||||
|
|
||||||
assertEquals(expectedGenerated, generated)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
"generate function with multiple args and defaults" {
|
||||||
fun `generate function with multiple args and defaults`() {
|
|
||||||
val functionSql = """
|
val functionSql = """
|
||||||
|create or replace function test_function_multiple (name text default 'plop', in hi text default 'hello', out result json)
|
|create or replace function test_function_multiple (name text default 'plop', in hi text default 'hello', out result json)
|
||||||
|language plpgsql
|
|language plpgsql
|
||||||
@@ -96,8 +89,6 @@ class FunctionGeneratorTest {
|
|||||||
|}
|
|}
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
|
|
||||||
val generated: String = generator.generate(Function(functionSql))
|
generator.generate(Function(functionSql)) `should be equal to` expectedGenerated
|
||||||
|
|
||||||
assertEquals(expectedGenerated, generated)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user