From bdfa83b5ed011b6698983ab0c334b51257a1ae7c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 18 Dec 2010 23:51:50 +0100 Subject: [PATCH] add more stuff to restest --- resolver_test.go | 32 ++++++++++++++++++++++++++++++++ restest.go | 13 +++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 resolver_test.go diff --git a/resolver_test.go b/resolver_test.go new file mode 100644 index 00000000..88b866c2 --- /dev/null +++ b/resolver_test.go @@ -0,0 +1,32 @@ +package dns + +import ( + "testing" + "time" +) + + +func TestResolver(t *testing.T) { + res := new(Resolver) + ch := NewQuerier(res) + + res.Servers = []string{"127.0.0.1"} + res.Timeout = 2 + res.Attempts = 1 + + m := new(Msg) + m.MsgHdr.Recursion_desired = true //only set this bit + m.Question = make([]Question, 1) + + // ask something + m.Question[0] = Question{"miek.nl", TypeSOA, ClassINET} + ch <- DnsMsg{m, nil} + in := <-ch + + if in.Dns.Rcode != RcodeSuccess { + t.Log("Failed to get an valid answer") + t.Fail() + } + ch <- DnsMsg{nil, nil} + time.Sleep(1.0e9) +} diff --git a/restest.go b/restest.go index f09a63f8..dce4d692 100644 --- a/restest.go +++ b/restest.go @@ -43,6 +43,19 @@ func main() { ch <- dns.DnsMsg{m, nil} in = <-ch fmt.Printf("%v\n", in.Dns) + + m.Question[0] = dns.Question{"nl", dns.TypeDNSKEY, dns.ClassINET} + ch <- dns.DnsMsg{m, nil} + in = <-ch + fmt.Printf("%v\n", in.Dns) + + m.Question[0] = dns.Question{"pa1ton.nl", dns.TypeDS, dns.ClassINET} + ch <- dns.DnsMsg{m, nil} + in = <-ch + fmt.Printf("%v\n", in.Dns) + + + } ch <- dns.DnsMsg{nil, nil}