Skip to content

Commit

Permalink
Change: update code and fixtures to reflect a change in the payload s…
Browse files Browse the repository at this point in the history
…chema
  • Loading branch information
ggalmazor committed Jan 26, 2024
1 parent d541ede commit 4866d73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions dnsimple/dns_analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type DnsAnalyticsService struct {

// DnsAnalytics represents DNS Analytics data.
type DnsAnalytics struct {
Volume int64
Zone string
Date string
Volume int64
ZoneName string
Date string
}

type DnsAnalyticsQueryParameters struct {
Expand Down Expand Up @@ -53,8 +53,8 @@ func (r *DnsAnalyticsResponse) marshalData() {
switch header {
case "volume":
dataEntry.Volume = int64(row[j].(float64))
case "zone":
dataEntry.Zone = row[j].(string)
case "zone_name":
dataEntry.ZoneName = row[j].(string)
case "date":
dataEntry.Date = row[j].(string)
}
Expand Down
10 changes: 5 additions & 5 deletions dnsimple/dns_analytics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestDnsAnalyticsService_Query(t *testing.T) {
assert.Len(t, data, 12)
assert.Equal(t, int64(1200), data[0].Volume)
assert.Equal(t, "2023-12-08", data[0].Date)
assert.Equal(t, "bar.com", data[0].Zone)
assert.Equal(t, "bar.com", data[0].ZoneName)
}

func TestDnsAnalyticsService_Query_SupportsFiltering(t *testing.T) {
Expand Down Expand Up @@ -67,15 +67,15 @@ func TestDnsAnalyticsService_Query_SupportsSorting(t *testing.T) {
testMethod(t, r, "GET")
testHeaders(t, r)
expectedQueryParameters := url.Values{}
expectedQueryParameters.Add("sort", "date:desc,zone:asc")
expectedQueryParameters.Add("sort", "date:desc,zone_name:asc")
testQuery(t, r, expectedQueryParameters)

w.WriteHeader(httpResponse.StatusCode)
_, _ = io.Copy(w, httpResponse.Body)
})

options := DnsAnalyticsOptions{}
options.Sort = String("date:desc,zone:asc")
options.Sort = String("date:desc,zone_name:asc")
_, _ = client.DnsAnalytics.Query(context.Background(), "1", &options)
}

Expand Down Expand Up @@ -113,12 +113,12 @@ func TestDnsAnalyticsService_Query_SupportsGrouping(t *testing.T) {
testMethod(t, r, "GET")
testHeaders(t, r)
expectedQueryParameters := url.Values{}
expectedQueryParameters.Add("groupings", "zone,date")
expectedQueryParameters.Add("groupings", "zone_name,date")
testQuery(t, r, expectedQueryParameters)

w.WriteHeader(httpResponse.StatusCode)
_, _ = io.Copy(w, httpResponse.Body)
})

_, _ = client.DnsAnalytics.Query(context.Background(), "1", &DnsAnalyticsOptions{Groupings: String("zone,date")})
_, _ = client.DnsAnalytics.Query(context.Background(), "1", &DnsAnalyticsOptions{Groupings: String("zone_name,date")})
}
2 changes: 1 addition & 1 deletion fixtures.http/api/dnsAnalytics/success.http
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000

{"data": {"headers": ["zone", "date", "volume"], "rows": [["bar.com", "2023-12-08", 1200], ["bar.com", "2023-12-09", 1200], ["bar.com", "2024-01-07", 1200], ["bar.com", "2024-01-08", 1200], ["example.com", "2023-12-08", 1200], ["example.com", "2023-12-09", 1200], ["example.com", "2024-01-07", 1200], ["example.com", "2024-01-08", 1200], ["foo.com", "2023-12-08", 1200], ["foo.com", "2023-12-09", 1200], ["foo.com", "2024-01-07", 1200], ["foo.com", "2024-01-08", 1200]]}, "query": {"account_id": 1, "start_date": "2023-12-08", "end_date": "2024-01-08", "sort": "zone:asc,date:asc", "page": 0, "per_page": 100, "groupings": "zone,date"}, "pagination": {"current_page": 0, "per_page": 100, "total_entries": 93, "total_pages": 1}}
{"data": {"headers": ["zone_name", "date", "volume"], "rows": [["bar.com", "2023-12-08", 1200], ["bar.com", "2023-12-09", 1200], ["bar.com", "2024-01-07", 1200], ["bar.com", "2024-01-08", 1200], ["example.com", "2023-12-08", 1200], ["example.com", "2023-12-09", 1200], ["example.com", "2024-01-07", 1200], ["example.com", "2024-01-08", 1200], ["foo.com", "2023-12-08", 1200], ["foo.com", "2023-12-09", 1200], ["foo.com", "2024-01-07", 1200], ["foo.com", "2024-01-08", 1200]]}, "query": {"account_id": 1, "start_date": "2023-12-08", "end_date": "2024-01-08", "sort": "zone_name:asc,date:asc", "page": 0, "per_page": 100, "groupings": "zone_name,date"}, "pagination": {"current_page": 0, "per_page": 100, "total_entries": 93, "total_pages": 1}}

0 comments on commit 4866d73

Please sign in to comment.