Debian Codegraph @

deleg/deleg_test.go

raw
1 package deleg_test
2
3 import (
4 "testing"
5
6 "codeberg.org/miekg/dns"
7 "codeberg.org/miekg/dns/dnstest"
8 )
9
10 func TestDELEG(t *testing.T) {
11 // TODO(miek): include more tests, or rename the test.
12 testcases := []struct {
13 in string
14 exp dns.RR
15 }{
16 {
17 "$ORIGIN example.\nexample. DELEG server-ipv4=192.0.2.1 server-ipv6=2001:DB8::1\n",
18 dnstest.New("example. IN 3600 DELEG server-ipv4=192.0.2.1 server-ipv6=2001:DB8::1"),
19 },
20 {
21 "$ORIGIN example.\nexample. DELEG server-name=ns2,ns3.example.org.\n",
22 dnstest.New("example. IN 3600 DELEG server-name=ns2.example.,ns3.example.org."),
23 },
24 {
25 "example. DELEG\n",
26 dnstest.New("example. IN 3600 DELEG"),
27 },
28 }
29 for i, tc := range testcases {
30 rr, err := dns.New(tc.in)
31 if err != nil {
32 t.Fatal(err)
33 }
34 t.Logf("%s\n", rr)
35 if !dns.Equal(rr, tc.exp) {
36 t.Errorf("test %d, expected %s, got %s", i, rr, tc.exp)
37 }
38 }
39 }