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