https://kotlinlang.org logo
Title
d

dave

01/20/2020, 7:32 AM
@Razi Kheir I've just rewritten the composite test to check that it works:
@Test
    fun `composite can use a mixture of overridden and non overridden values`() {
        data class Target(val foo: String, val bar: Int, var foobar: Int?)

        val finalEnv = from("bar" to "123") overrides from("FOO" to "bill")

        val key = EnvironmentKey.composite {
            Target(
                required("FOO")(it),
                int().required("BAR")(it),
                int().optional("FOOBAR")(it)
            )
        }

        assertThat(key(finalEnv), equalTo(Target("bill", 123, null)))
    }
}
😁 1
r

Razi Kheir

01/21/2020, 1:51 AM
Using this way works for optional composites 🙂 Don’t know why I used the spec thing from the tests, this is actually much nicer! Thanks again Dave 🙂
d

dave

01/21/2020, 6:33 AM
There isn't an example of the composite config on the site. I'll try to add one.
👍 1
r

Razi Kheir

01/22/2020, 7:57 AM
Is your website source tracked in repo too? If so I don’t mind adding it 🙂
d

dave

01/22/2020, 8:12 AM
@Razi Kheir thanks! You can add it to here and it will get automatically built into the right place: https://github.com/http4k/http4k/tree/master/src/docs/guide/modules/cloud_native
🎉 1
r

Razi Kheir

01/23/2020, 12:31 AM
Will do 🙂