Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More lenient DnsTest #474

Merged
merged 2 commits into from
Mar 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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