Skip to content

Commit

Permalink
test: improve assertion message in test-dns-any
Browse files Browse the repository at this point in the history
Improve error message from "The expression evaluated to a falsy value"
to a message formatted dynamically that lists the record types found so
that someone investigating can look at the code and determine which
values are missing.

This came up because the test failed in nightly master branch CI but
generally passes. It may prove helpful to know what record types were
missing. (All of them? Just one? Something else?)

PR-URL: #31697
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and codebytere committed Mar 30, 2020
1 parent 249a0fe commit 59eba11
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/internet/test-dns-any.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ TEST(async function test_google(done) {
function validateResult(res) {
const types = processResult(res);
assert.ok(
types.A && types.AAAA && types.MX &&
types.NS && types.TXT && types.SOA);
types.A && types.AAAA && types.MX && types.NS && types.TXT && types.SOA,
`Missing record type, found ${Object.keys(types)}`);
}

validateResult(await dnsPromises.resolve('google.com', 'ANY'));
Expand All @@ -140,7 +140,8 @@ TEST(async function test_google(done) {
TEST(async function test_sip2sip_for_naptr(done) {
function validateResult(res) {
const types = processResult(res);
assert.ok(types.A && types.NS && types.NAPTR && types.SOA);
assert.ok(types.A && types.NS && types.NAPTR && types.SOA,
`Missing record type, found ${Object.keys(types)}`);
}

validateResult(await dnsPromises.resolve('sip2sip.info', 'ANY'));
Expand Down

0 comments on commit 59eba11

Please sign in to comment.