/
dyn_test.go
60 lines (54 loc) · 1.05 KB
/
dyn_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package dns
import (
"net"
"testing"
)
func sendit(u *Msg) (r *Msg, e error) {
c := new(Client)
r, e = c.Exchange(u, "127.0.0.1:53")
return r, e
}
func TestUpdateAdd(t *testing.T) {
u := new(Msg)
u.SetUpdate("dyn.atoom.net.")
a := new(RR_A)
a.Hdr = RR_Header{"miek2.dyn.atoom.net.", TypeA, ClassINET, 1000, 0}
a.A = net.IPv4(127, 0, 0, 1)
rr := make([]RR, 1)
rr[0] = a
u.RRsetAddRdata(rr)
t.Log(u.String())
r, e := sendit(u)
if e != nil {
t.Log("Failed: " + e.Error())
t.Fail()
}
if r != nil && r.Rcode != RcodeSuccess {
t.Log("Failed: " + r.String())
t.Fail()
}
t.Log(r.String())
}
func TestUpdateDelete(t *testing.T) {
u := new(Msg)
u.SetUpdate("dyn.atoom.net.")
a := new(RR_A)
a.Hdr = RR_Header{"miek2.dyn.atoom.net.", TypeA, ClassINET, 1000, 0}
a.A = nil
rr := make([]RR, 1)
rr[0] = a
u.RRsetDelete(rr)
t.Log(u.String())
r, e := sendit(u)
if e != nil {
t.Log("Failed: " + e.Error())
t.Fail()
return
}
if r != nil && r.Rcode != RcodeSuccess {
t.Log("Failed: " + r.String())
t.Fail()
return
}
t.Log(r.String())
}