From 603e32d4faa865fe2251f738e1d2cbdc4c5d53ae Mon Sep 17 00:00:00 2001 From: Matthias Hochgatterer Date: Fri, 7 Nov 2014 13:44:29 +0100 Subject: [PATCH] Add unit test --- zone_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/zone_test.go b/zone_test.go index 23cf511..082d72d 100644 --- a/zone_test.go +++ b/zone_test.go @@ -256,3 +256,20 @@ func TestMDNSService_HostNameQuery(t *testing.T) { } } } + +func TestMDNSService_serviceEnum_PTR(t *testing.T) { + s := makeService(t) + q := dns.Question{ + Name: "_services._dns-sd._udp.local.", + Qtype: dns.TypePTR, + } + recs := s.Records(q) + if len(recs) != 1 { + t.Fatalf("bad: %v", recs) + } + if ptr, ok := recs[0].(*dns.PTR); !ok { + t.Errorf("recs[0] should be PTR record, got: %v, all records: %v", recs[0], recs) + } else if got, want := ptr.Ptr, "_http._tcp.local."; got != want { + t.Fatalf("bad PTR record %v: got %v, want %v", ptr, got, want) + } +}