diff options
| author | Matt Mastracci <matthew@mastracci.com> | 2024-02-10 13:22:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 20:22:13 +0000 |
| commit | f5e46c9bf2f50d66a953fa133161fc829cecff06 (patch) | |
| tree | 8faf2f5831c1c7b11d842cd9908d141082c869a5 /tests/testdata/run/resolve_dns.ts | |
| parent | d2477f780630a812bfd65e3987b70c0d309385bb (diff) | |
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests ->
tests, and updates of relative paths for files.
This is the first step towards aggregate all of the integration test
files under tests/, which will lead to a set of integration tests that
can run without the CLI binary being built.
While we could leave these tests under `cli`, it would require us to
keep a more complex directory structure for the various test runners. In
addition, we have a lot of complexity to ignore various test files in
the `cli` project itself (cargo publish exclusion rules, autotests =
false, etc).
And finally, the `tests/` folder will eventually house the `test_ffi`,
`test_napi` and other testing code, reducing the size of the root repo
directory.
For easier review, the extremely large and noisy "move" is in the first
commit (with no changes -- just a move), while the remainder of the
changes to actual files is in the second commit.
Diffstat (limited to 'tests/testdata/run/resolve_dns.ts')
| -rw-r--r-- | tests/testdata/run/resolve_dns.ts | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/tests/testdata/run/resolve_dns.ts b/tests/testdata/run/resolve_dns.ts new file mode 100644 index 000000000..a2d0fd046 --- /dev/null +++ b/tests/testdata/run/resolve_dns.ts @@ -0,0 +1,93 @@ +const nameServer = { nameServer: { ipAddr: "127.0.0.1", port: 4553 } }; + +const [a, aaaa, aname, caa, cname, mx, naptr, ns, ptr, soa, srv, txt] = + await Promise + .all([ + Deno.resolveDns("www.example.com", "A", nameServer), + Deno.resolveDns("www.example.com", "AAAA", nameServer), + Deno.resolveDns("www.example.com", "ANAME", nameServer), + Deno.resolveDns("example.com", "CAA", nameServer), + Deno.resolveDns("alias.example.com", "CNAME", nameServer), + Deno.resolveDns("example.com", "MX", nameServer), + Deno.resolveDns("example.com", "NAPTR", nameServer), + Deno.resolveDns("example.com", "NS", nameServer), + Deno.resolveDns("1.2.3.4.IN-ADDR.ARPA.", "PTR", nameServer), + Deno.resolveDns("example.com", "SOA", nameServer), + Deno.resolveDns("_service._tcp.example.com", "SRV", nameServer), + Deno.resolveDns("example.com", "TXT", nameServer), + ]); + +console.log("A"); +console.log(JSON.stringify(a)); + +console.log("AAAA"); +console.log(JSON.stringify(aaaa)); + +console.log("ANAME"); +console.log(JSON.stringify(aname)); + +console.log("CAA"); +console.log(JSON.stringify(caa)); + +console.log("CNAME"); +console.log(JSON.stringify(cname)); + +console.log("MX"); +console.log(JSON.stringify(mx)); + +console.log("NAPTR"); +console.log(JSON.stringify(naptr)); + +console.log("NS"); +console.log(JSON.stringify(ns)); + +console.log("PTR"); +console.log(JSON.stringify(ptr)); + +console.log("SOA"); +console.log(JSON.stringify(soa)); + +console.log("SRV"); +console.log(JSON.stringify(srv)); + +console.log("TXT"); +console.log(JSON.stringify(txt)); + +try { + await Deno.resolveDns("not-found-example.com", "A", nameServer); +} catch (e) { + console.log( + `Error ${ + e instanceof Error ? e.name : "[non-error]" + } thrown for not-found-example.com`, + ); +} + +try { + // @ts-ignore testing invalid overloads + await Deno.resolveDns("example.com", "SSHFP", nameServer); +} catch (e) { + console.log(e.message); +} + +try { + const ac = new AbortController(); + queueMicrotask(() => ac.abort()); + await Deno.resolveDns("www.example.com", "A", { + ...nameServer, + signal: ac.signal, + }); +} catch (e) { + console.log(e.name); +} + +try { + const ac = new AbortController(); + ac.abort(); + await Deno.resolveDns("www.example.com", "A", { + ...nameServer, + signal: ac.signal, + }); +} catch (e) { + console.log(e.name); +} |
