Fix the tests

This commit is contained in:
Miek Gieben 2012-10-09 22:15:33 +02:00
parent 83b362dce6
commit ca8b17dda2
2 changed files with 17 additions and 17 deletions

View File

@ -14,13 +14,13 @@ func TestPackUnpack(t *testing.T) {
key.PublicKey = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ"
out.Answer[0] = key
msg, ok := out.Pack()
if !ok {
msg, err := out.Pack()
if err != nil {
t.Log("Failed to pack msg with DNSKEY")
t.Fail()
}
in := new(Msg)
if !in.Unpack(msg) {
if in.Unpack(msg) != nil {
t.Log("Failed to unpack msg with DNSKEY")
t.Fail()
}
@ -32,13 +32,13 @@ func TestPackUnpack(t *testing.T) {
sig.Hdr = RR_Header{Name: "miek.nl.", Rrtype: TypeRRSIG, Class: ClassINET, Ttl: 3600}
out.Answer[0] = sig
msg, ok = out.Pack()
if !ok {
msg, err = out.Pack()
if err != nil {
t.Log("Failed to pack msg with RRSIG")
t.Fail()
}
if !in.Unpack(msg) {
if in.Unpack(msg) != nil {
t.Log("Failed to unpack msg with RRSIG")
t.Fail()
}
@ -59,8 +59,8 @@ func TestPackUnpack2(t *testing.T) {
m.Extra[0] = x
m.Answer[0] = rr
_, ok := m.Pack()
if !ok {
_, err := m.Pack()
if err != nil {
t.Log("Packing failed")
t.Fail()
return
@ -106,7 +106,7 @@ func TestPack(t *testing.T) {
t.Fail()
continue
}
if _, ok := m.Pack(); !ok {
if _, err := m.Pack(); err != nil {
t.Log("Packing failed")
t.Fail()
}
@ -119,19 +119,19 @@ func TestPack(t *testing.T) {
x.Ns = append(m.Ns, ns)
// This crashes due to the fact the a.ntpns.org isn't a FQDN
// How to recover() from a remove panic()?
if _, ok := x.Pack(); ok {
if _, err := x.Pack(); err == nil {
t.Log("Packing should fail")
t.Fail()
}
x.Answer = make([]RR, 1)
x.Answer[0], err = NewRR(rr[0])
if _, ok := x.Pack(); ok {
if _, err := x.Pack(); err == nil {
t.Log("Packing should fail")
t.Fail()
}
x.Question = make([]Question, 1)
x.Question[0] = Question{";sd#edddds鍛↙赏‘℅∥↙xzztsestxssweewwsssstx@s@Z嵌e@cn.pool.ntp.org.", TypeA, ClassINET}
if _, ok := x.Pack(); ok {
if _, err := x.Pack(); err == nil {
t.Log("Packing should fail")
t.Fail()
}

View File

@ -181,13 +181,13 @@ func TestDomainName(t *testing.T) {
dbuff := make([]byte, 40)
for _, ts := range tests {
if _, ok := PackDomainName(ts, dbuff, 0, nil, false); !ok {
if _, err := PackDomainName(ts, dbuff, 0, nil, false); err != nil {
t.Log("Not a valid domain name")
t.Fail()
continue
}
n, _, ok := UnpackDomainName(dbuff, 0)
if !ok {
n, _, err := UnpackDomainName(dbuff, 0)
if err != nil {
t.Log("Failed to unpack packed domain name")
t.Fail()
continue
@ -620,8 +620,8 @@ func TestSRVPacking(t *testing.T) {
msg.Answer = append(msg.Answer, rr)
}
_, ok := msg.Pack()
if !ok {
_, err := msg.Pack()
if err != nil{
t.Fatalf("Couldn't pack %v\n", msg)
}
}