File: domains_zones_test.go

package info (click to toggle)
golang-github-weppos-dnsimple-go 0.0~git20160204.0.65c1ca7-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 144 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download | duplicates (2)
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
package dnsimple

import (
	"fmt"
	"net/http"
	"reflect"
	"testing"
)

func TestDomainsService_GetZone(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/v1/domains/example.com/zone", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "GET")
		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"}`)
	})

	zone, _, err := client.Domains.GetZone("example.com")

	if err != nil {
		t.Errorf("Zones.Get returned error: %v", err)
	}

	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"
	if !reflect.DeepEqual(zone, want) {
		t.Errorf("Zones.Get returned %+v, want %+v", zone, want)
	}
}