-
Notifications
You must be signed in to change notification settings - Fork 0
/
ns_test.go
57 lines (52 loc) · 1.54 KB
/
ns_test.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package namecheap
import (
"fmt"
"net/http"
"net/url"
"reflect"
"testing"
)
func TestNSGetInfo(t *testing.T) {
setup()
defer teardown()
respXML := `
<?xml version="1.0" encoding="UTF-8"?>
<ApiResponse xmlns="http://api.namecheap.com/xml.response" Status="OK">
<Errors />
<RequestedCommand>namecheap.domains.ns.getInfo</RequestedCommand>
<CommandResponse Type="namecheap.domains.ns.getInfo">
<DomainNSInfoResult Domain="domain.com" Nameserver="ns1.domain.com" IP="12.23.23.23">
<NameserverStatuses>
<Status>OK</Status>
<Status>Linked</Status>
</NameserverStatuses>
</DomainNSInfoResult>
</CommandResponse>
<Server>SERVER-NAME</Server>
<GMTTimeDifference>+5</GMTTimeDifference>
<ExecutionTime>32.76</ExecutionTime>
</ApiResponse>`
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
correctParams := fillDefaultParams(url.Values{})
correctParams.Set("Command", "namecheap.domains.ns.getInfo")
correctParams.Set("Nameserver", "ns1.domain.com")
correctParams.Set("SLD", "domain")
correctParams.Set("TLD", "com")
testBody(t, r, correctParams)
testMethod(t, r, "POST")
fmt.Fprint(w, respXML)
})
ns, err := client.NSGetInfo("domain", "com", "ns1.domain.com")
if err != nil {
t.Errorf("NSGetInfo returned error: %v", err)
}
want := &DomainNSInfoResult{
Domain: "domain.com",
Nameserver: "ns1.domain.com",
IP: "12.23.23.23",
Statuses: []string{"OK", "Linked"},
}
if !reflect.DeepEqual(ns, want) {
t.Errorf("NSGetInfo returned %+v, want %+v", ns, want)
}
}