Add unit test for build-logic static ip tool.

This commit is contained in:
Alex Hart
2023-03-01 11:29:02 -04:00
committed by Greyson Parrelli
parent 43aad90ee4
commit 3f62221182
2 changed files with 19 additions and 6 deletions

View File

@@ -20,12 +20,23 @@ class StaticIpResolverTest {
@Test
fun `Given a hostname with records, when I resolveToBuildConfig, then I expect a matching IP`() {
val staticIpResolver = StaticIpResolver(FakeRecordFetcher(mapOf(
SIGNAL_DOT_ORG to arrayOf(ARecord(Name.fromString("www."), DClass.ANY, 0L, mockk<Inet4Address> {
every { address } returns SIGNAL_IP
every { hostAddress } returns STRINGIFIED_IP
}))
)))
val staticIpResolver = StaticIpResolver(
FakeRecordFetcher(
mapOf(
SIGNAL_DOT_ORG to arrayOf(
ARecord(
Name.fromString("www."),
DClass.ANY,
0L,
mockk<Inet4Address> {
every { address } returns SIGNAL_IP
every { hostAddress } returns STRINGIFIED_IP
}
)
)
)
)
)
val actual = staticIpResolver.resolveToBuildConfig(SIGNAL_DOT_ORG)
val expected = """
new String[]{"$STRINGIFIED_IP"}