Skip to content

Commit

Permalink
chore: Test resetting options
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Oct 22, 2023
1 parent 0caf6ca commit 64343e5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,25 @@ internal class PatchOptionsTest {
@Test
fun `should allow resetting value`() = assertDoesNotThrow { OptionsTestPatch.stringOptionWithChoices = null }

@Test
fun `reset should not fail`() {
assertDoesNotThrow {
OptionsTestPatch.resettableOption.value = "test"
OptionsTestPatch.resettableOption.reset()
}

assertThrows<PatchOptionException.ValueRequiredException> {
OptionsTestPatch.resettableOption.value
}
}

private object OptionsTestPatch : BytecodePatch() {
var booleanOption by booleanPatchOption("bool", true)
var requiredStringOption by stringPatchOption("required", "default", required = true)
var stringArrayOption = stringArrayPatchOption("array", arrayOf("1", "2"))
var stringOptionWithChoices by stringPatchOption("choices", "value", values = setOf("valid"))
var validatedOption by stringPatchOption("validated", "default") { it == "valid" }
var resettableOption = stringPatchOption("resettable", null, required = true)

override fun execute(context: BytecodeContext) {}
}
Expand Down

0 comments on commit 64343e5

Please sign in to comment.