Skip to content

Instantly share code, notes, and snippets.

@delabassee
Created July 23, 2018 11:23
Show Gist options
  • Save delabassee/3ef986d8b37e1be6490fa59e95d3833c to your computer and use it in GitHub Desktop.
Save delabassee/3ef986d8b37e1be6490fa59e95d3833c to your computer and use it in GitHub Desktop.
package com.fn.example
import com.fnproject.fn.testing.*
import org.junit.*
import kotlin.test.assertEquals
class HelloFunctionTest {
@Rule @JvmField
val fn = FnTestingRule.createDefault()
@Test
fun `should return default greeting`() {
with (fn) {
givenEvent().enqueue()
thenRun("com.fn.example.HelloFunctionKt","hello")
assertEquals("Hello, world!", getOnlyResult().getBodyAsString())
}
}
@Test
fun `should return personalized greeting`() {
with (fn) {
givenEvent().withBody("Jhonny").enqueue()
thenRun("com.fn.example.HelloFunctionKt","hello")
assertEquals("Hello, Jhonny", getOnlyResult().getBodyAsString())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment