Debian Codegraph @

dnsimple/domains_zones_test.go

raw
1 package dnsimple
2
3 import (
4 "fmt"
5 "net/http"
6 "reflect"
7 "testing"
8 )
9
10 func TestDomainsService_GetZone(t *testing.T) {
11 setup()
12 defer teardown()
13
14 mux.HandleFunc("/v1/domains/example.com/zone", func(w http.ResponseWriter, r *http.Request) {
15 testMethod(t, r, "GET")
16 fmt.Fprint(w, `{"zone":"$ORIGIN example-1417880719.com.\n$TTL 1h\nexample-1417880719.com. 3600 IN SOA ns1.dnsimple.com. admin.dnsimple.com. 2014120601 86400 7200 604800 300\nexample-1417880719.com. 3600 IN NS ns2.dnsimple.com.\nexample-1417880719.com. 3600 IN NS ns1.dnsimple.com.\nexample-1417880719.com. 3600 IN NS ns3.dnsimple.com.\nexample-1417880719.com. 3600 IN NS ns4.dnsimple.com.\n"}`)
17 })
18
19 zone, _, err := client.Domains.GetZone("example.com")
20
21 if err != nil {
22 t.Errorf("Zones.Get returned error: %v", err)
23 }
24
25 want := "$ORIGIN example-1417880719.com.\n$TTL 1h\nexample-1417880719.com. 3600 IN SOA ns1.dnsimple.com. admin.dnsimple.com. 2014120601 86400 7200 604800 300\nexample-1417880719.com. 3600 IN NS ns2.dnsimple.com.\nexample-1417880719.com. 3600 IN NS ns1.dnsimple.com.\nexample-1417880719.com. 3600 IN NS ns3.dnsimple.com.\nexample-1417880719.com. 3600 IN NS ns4.dnsimple.com.\n"
26 if !reflect.DeepEqual(zone, want) {
27 t.Errorf("Zones.Get returned %+v, want %+v", zone, want)
28 }
29 }