Skip to content

Commit

Permalink
more approval tests for various scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddenton committed Apr 24, 2024
1 parent 71a8d9c commit 93c9f89
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
}

@Test
fun `can write primitives values`() {
fun `can write primitives values`(approver: Approver) {
val input = container(
mapOf(
"string" to "string",
Expand Down Expand Up @@ -199,6 +199,8 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
expectSetWorks(input::optional, "123123")
expectSetWorks(input::optional, null)
expectSetWorks(input::mapped, 123)

approver.assertApproved(input.toString())
}

@Test
Expand All @@ -223,14 +225,16 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
}

@Test
fun `read and write data values`() {
fun `read and write data values`(approver: Approver) {
val inner = data(mutableMapOf("name" to "string"))
val outer = container(mapOf("requiredData" to inner))

expectThat(outer.requiredData).isEqualTo(inner)
expectThat(outer.optionalData).isNull()
outer.optionalData = inner
expectThat(outer.optionalData).isEqualTo(inner)

approver.assertApproved(inner.toString())
}

@Test
Expand Down Expand Up @@ -292,7 +296,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
}

@Test
fun `write list values`() {
fun `write list values`(approver: Approver) {
val input = container(
mapOf(
"list" to listOf("string1", "string2"),
Expand All @@ -311,6 +315,8 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
expectSetWorks(input::optionalSubClassList, listOf(childContainer(mapOf("123" to "123"))))
expectSetWorks(input::optionalValueList, listOf(MyType.of(123), MyType.of(456)))
expectSetWorks(input::optionalList, listOf("hello"))

approver.assertApproved(input.toString())
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"string":"123","boolean":false,"int":999,"long":0,"double":5.4536,"value":123,"mapped":"123","optionalValue":123,"optional":null,"localDateValue":"1999-12-12","stringValue":"123","booleanValue":false,"intValue":123}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"string"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"list":["123"],"listSubClass":[{"123":"123"}],"listValue":["+999999999-12-31","-999999999-01-01","1970-01-01"],"optionalList":["hello"],"optionalSubClassList":[{"123":"123"}],"optionalValueList":[123,456]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{string=123, boolean=false, int=999, long=0, double=5.4536, value=123, mapped=123, optionalValue=123, optional=null, localDateValue=1999-12-12, stringValue=123, booleanValue=false, intValue=123}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{name=string}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{list=[123], listSubClass=[{123=123}], listValue=[+999999999-12-31, -999999999-01-01, 1970-01-01], optionalList=[hello], optionalSubClassList=[{123=123}], optionalValueList=[123, 456]}

0 comments on commit 93c9f89

Please sign in to comment.