Skip to content

Commit

Permalink
Merge pull request #474 from armanbilge/topic/more-lenient-dns-test
Browse files Browse the repository at this point in the history
More lenient `DnsTest`
  • Loading branch information
mpilquist authored Mar 19, 2023
2 parents 9a0a68e + 660e2f3 commit db9ce20
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test-kit/shared/src/test/scala/com/comcast/ip4s/DnsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@ class DnsTest extends CatsEffectSuite {
}

test("loopback") {
assertIO(Dns[IO].loopback.map(_.some), IpAddress.fromString("127.0.0.1"))
val loopbacks = Set(ip"127.0.0.1", ip"::1")
Dns[IO].loopback.flatMap { loopback =>
IO(assert(loopbacks.contains(clue(loopback))))
}
}

test("resolve unknown host") {
Dns[IO]
.resolve(host"not.example.com")
.interceptMessage[UnknownHostException]("not.example.com: Name or service not known")
(Dns[IO].resolve(host"not.example.com") >>
IO.raiseError(new AssertionError("Did not raise `UnknownHostException`"))).recover {
case ex: UnknownHostException =>
assert(
ex.getMessage == "not.example.com: Name or service not known" || ex.getMessage == "not.example.com: nodename nor servname provided, or not known"
)
}
}

test("reverse unknown ip") {
Expand Down

0 comments on commit db9ce20

Please sign in to comment.