Skip to content

Commit

Permalink
fix(dns): fix struct field
Browse files Browse the repository at this point in the history
  • Loading branch information
johntdyer authored Apr 10, 2020
1 parent a02a469 commit 5a0b8ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dns_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type DNSServer struct {
MtuMeasurements int `json:"mtuMeasurements,omitempty"`
NetworkMeasurements int `json:"networkMeasurements,omitempty"`
NumPathTraces int `json:"numPathTraces,omitempty"`
PathTraceMode string `json:"pathTraceMode,omitempty"`
ProbeMode string `json:"probeMode,omitempty"`
Protocol string `json:"protocol,omitempty"`
RecursiveQueries int `json:"recursiveQueries,omitempty"`
Expand All @@ -56,7 +57,7 @@ func (t *DNSServer) AddAlertRule(id int) {
t.AlertRules = append(t.AlertRules, alertRule)
}

// GetDNSServer - get dns server test
//GetDNSServer - get dns server test
func (c *Client) GetDNSServer(id int) (*DNSServer, error) {
resp, err := c.get(fmt.Sprintf("/tests/%d", id))
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions dns_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestClient_GetDNSServer(t *testing.T) {
out := `{"test":[{"createdDate":"2020-02-06 15:28:07","createdBy":"William Fleming ([email protected])","enabled":1,"savedEvent":0,"testId":122621,"testName":"test123","type":"dns-server","interval":300,"protocol":"UDP","networkMeasurements":1,"mtuMeasurements":1,"bandwidthMeasurements":0,"bgpMeasurements":1,"usePublicBgp":1,"alertsEnabled":1,"liveShare":0,"probeMode":"AUTO","agents":[{"agentId":48620,"agentName":"Seattle, WA (Trial) - IPv6","agentType":"Cloud","countryId":"US","ipAddresses":["135.84.184.153"],"location":"Seattle Area","network":"Astute Hosting Inc. (AS 54527)","prefix":"135.84.184.0/22"}],"sharedWithAccounts":[{"aid":176592,"name":"Cloudreach"}],"bgpMonitors":[{"monitorId":64,"ipAddress":"2001:240:100:ff::2497:2","countryId":"JP","monitorName":"Tokyo-3","network":"IIJ Internet Initiative Japan Inc. (AS 2497)","monitorType":"Public"}],"numPathTraces":3,"domain": "webex.com","dnsTransportProtocol": "UDP", "dnsServers" : [{"serverId": 123,"serverName":"1.1.1.1"}],"apiLinks":[{"rel":"self","href":"https://api.thousandeyes.com/v6/tests/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/web/dns-server/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/metrics/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/path-vis/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/bgp-metrics/1226221"}]}]}`
out := `{"test":[{"createdDate":"2020-02-06 15:28:07","createdBy":"William Fleming ([email protected])","numPathTraces":3,"pathTraceMode": "classic", "enabled":1,"savedEvent":0,"testId":122621,"testName":"test123","type":"dns-server","interval":300,"protocol":"UDP","networkMeasurements":1,"mtuMeasurements":1,"bandwidthMeasurements":0,"bgpMeasurements":1,"usePublicBgp":1,"alertsEnabled":1,"liveShare":0,"probeMode":"AUTO","agents":[{"agentId":48620,"agentName":"Seattle, WA (Trial) - IPv6","agentType":"Cloud","countryId":"US","ipAddresses":["135.84.184.153"],"location":"Seattle Area","network":"Astute Hosting Inc. (AS 54527)","prefix":"135.84.184.0/22"}],"sharedWithAccounts":[{"aid":176592,"name":"Cloudreach"}],"bgpMonitors":[{"monitorId":64,"ipAddress":"2001:240:100:ff::2497:2","countryId":"JP","monitorName":"Tokyo-3","network":"IIJ Internet Initiative Japan Inc. (AS 2497)","monitorType":"Public"}],"numPathTraces":3,"domain": "webex.com","dnsTransportProtocol": "UDP", "dnsServers" : [{"serverId": 123,"serverName":"1.1.1.1"}],"apiLinks":[{"rel":"self","href":"https://api.thousandeyes.com/v6/tests/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/web/dns-server/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/metrics/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/path-vis/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/bgp-metrics/1226221"}]}]}`
setup()
var client = &Client{APIEndpoint: server.URL, AuthToken: "foo"}
mux.HandleFunc("/tests/122621.json", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -32,6 +32,7 @@ func TestClient_GetDNSServer(t *testing.T) {
MtuMeasurements: 1,
BandwidthMeasurements: 0,
NumPathTraces: 3,
PathTraceMode: "classic",
AlertsEnabled: 1,
RecursiveQueries: 0,
BgpMeasurements: 1,
Expand Down Expand Up @@ -122,7 +123,7 @@ func TestClient_GetDNSServerJsonError(t *testing.T) {
}

func TestClient_CreateDNSServer(t *testing.T) {
out := `{"test":[{"createdDate":"2020-02-06 15:28:07","createdBy":"William Fleming ([email protected])","enabled":1,"savedEvent":0,"testId":122621,"testName":"test123","type":"dns-server","interval":300,"protocol":"UDP","networkMeasurements":1,"mtuMeasurements":1,"bandwidthMeasurements":0,"bgpMeasurements":1,"usePublicBgp":1,"alertsEnabled":1,"liveShare":0,"probeMode":"AUTO","agents":[{"agentId":48620,"agentName":"Seattle, WA (Trial) - IPv6","agentType":"Cloud","countryId":"US","ipAddresses":["135.84.184.153"],"location":"Seattle Area","network":"Astute Hosting Inc. (AS 54527)","prefix":"135.84.184.0/22"}],"sharedWithAccounts":[{"aid":176592,"name":"Cloudreach"}],"bgpMonitors":[{"monitorId":64,"ipAddress":"2001:240:100:ff::2497:2","countryId":"JP","monitorName":"Tokyo-3","network":"IIJ Internet Initiative Japan Inc. (AS 2497)","monitorType":"Public"}],"numPathTraces":3,"domain": "webex.com","dnsTransportProtocol": "UDP", "dnsServers" : [{"serverId": 123,"serverName":"1.1.1.1"}],"apiLinks":[{"rel":"self","href":"https://api.thousandeyes.com/v6/tests/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/web/dns-server/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/metrics/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/path-vis/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/bgp-metrics/1226221"}]}]}`
out := `{"test":[{"createdDate":"2020-02-06 15:28:07","createdBy":"William Fleming ([email protected])","numPathTraces": 3,"enabled":1,"savedEvent":0,"testId":122621,"testName":"test123","type":"dns-server","interval":300,"protocol":"UDP","networkMeasurements":1,"mtuMeasurements":1,"bandwidthMeasurements":0,"bgpMeasurements":1,"usePublicBgp":1,"alertsEnabled":1,"liveShare":0,"probeMode":"AUTO","agents":[{"agentId":48620,"agentName":"Seattle, WA (Trial) - IPv6","agentType":"Cloud","countryId":"US","ipAddresses":["135.84.184.153"],"location":"Seattle Area","network":"Astute Hosting Inc. (AS 54527)","prefix":"135.84.184.0/22"}],"sharedWithAccounts":[{"aid":176592,"name":"Cloudreach"}],"bgpMonitors":[{"monitorId":64,"ipAddress":"2001:240:100:ff::2497:2","countryId":"JP","monitorName":"Tokyo-3","network":"IIJ Internet Initiative Japan Inc. (AS 2497)","monitorType":"Public"}],"numPathTraces":3,"domain": "webex.com","dnsTransportProtocol": "UDP", "dnsServers" : [{"serverId": 123,"serverName":"1.1.1.1"}],"apiLinks":[{"rel":"self","href":"https://api.thousandeyes.com/v6/tests/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/web/dns-server/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/metrics/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/path-vis/1226221"},{"rel":"data","href":"https://api.thousandeyes.com/v6/net/bgp-metrics/1226221"}]}]}`
setup()
var client = &Client{APIEndpoint: server.URL, AuthToken: "foo"}
mux.HandleFunc("/tests/dns-server/new.json", func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -211,9 +212,10 @@ func TestClient_CreateDNSServer(t *testing.T) {
},
}
create := DNSServer{
TestName: "test1",
Domain: "1.1.1.1",
Interval: 300,
TestName: "test1",
Domain: "1.1.1.1",
Interval: 300,
NumPathTraces: 3,
}
res, err := client.CreateDNSServer(create)
teardown()
Expand Down

0 comments on commit 5a0b8ad

Please sign in to comment.