Skip to content

Commit

Permalink
Update unit tests to correctly show total_count
Browse files Browse the repository at this point in the history
  • Loading branch information
jroyal committed Aug 24, 2023
1 parent db99800 commit 5b8eed4
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion access_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestAccessApplications(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
2 changes: 1 addition & 1 deletion access_bookmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccessBookmarks(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
2 changes: 1 addition & 1 deletion access_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestAccessGroups(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
6 changes: 3 additions & 3 deletions account_members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestAccountMembers(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -459,7 +459,7 @@ func TestUpdateAccountMember(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -523,7 +523,7 @@ func TestUpdateAccountMemberWithPolicies(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down
4 changes: 2 additions & 2 deletions account_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestAccountRoles(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestAccountRole(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
6 changes: 3 additions & 3 deletions accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestAccounts(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestAccount(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestCreateAccount(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
2 changes: 1 addition & 1 deletion cloudflare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestClient_RetryCanSucceedAfterErrors(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down
12 changes: 6 additions & 6 deletions custom_pages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestCustomPagesForZone(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestCustomPagesForAccount(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestCustomPageForZone(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestCustomPageForAccount(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestUpdateCustomPagesForAccount(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestUpdateCustomPagesForZone(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
4 changes: 2 additions & 2 deletions device_posture_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestDevicePostureIntegrations(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestDevicePostureRules(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
6 changes: 3 additions & 3 deletions dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestListDNSRecords(t *testing.T) {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func TestListDNSRecordsSearch(t *testing.T) {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestListDNSRecordsSearch(t *testing.T) {
Tags: []string{"tag1", "tag2"},
})
require.NoError(t, err)
assert.Equal(t, 2000, resultInfo.Total)
assert.Equal(t, 1, resultInfo.Total)

assert.Equal(t, want, actual)
}
Expand Down
6 changes: 3 additions & 3 deletions load_balancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func TestListLoadBalancerPools(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -760,7 +760,7 @@ func TestListLoadBalancerMonitors(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -1497,7 +1497,7 @@ func TestListLoadBalancers(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down
2 changes: 1 addition & 1 deletion lockdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestListZoneLockdowns(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down
2 changes: 1 addition & 1 deletion origin_ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestOriginCA_OriginCertificates(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
})
Expand Down
2 changes: 1 addition & 1 deletion pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math"
)

// Look first for total_pages, but if total_count and per_page are set then use that to get page count
// Look first for total_pages, but if total_count and per_page are set then use that to get page count.
func (p ResultInfo) getTotalPages() int {
totalPages := p.TotalPages
if totalPages == 0 && p.Total > 0 && p.PerPage > 0 {
Expand Down
6 changes: 3 additions & 3 deletions registrar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TestRegistrarDomains(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestTransferRegistrarDomain(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down Expand Up @@ -297,7 +297,7 @@ func TestCancelRegistrarDomainTransfer(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}
`)
Expand Down
4 changes: 2 additions & 2 deletions ssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestListSSL(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -330,7 +330,7 @@ func TestReprioritizeSSL(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down
6 changes: 3 additions & 3 deletions teams_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestTeamsLists(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000,
"total_count": 1,
"total_pages": 1
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestTeamsList(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000,
"total_count": 1,
"total_pages": 1
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestTeamsListItems(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000,
"total_count": 1,
"total_pages": 1
}
}
Expand Down
2 changes: 1 addition & 1 deletion turnstile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestTurnstileWidget_List(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
})
Expand Down
6 changes: 3 additions & 3 deletions waf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestListWAFPackages(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestListWAFGroups(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down Expand Up @@ -532,7 +532,7 @@ func TestListWAFRules(t *testing.T) {
"page": 1,
"per_page": 20,
"count": 1,
"total_count": 2000
"total_count": 1
}
}`)
}
Expand Down

0 comments on commit 5b8eed4

Please sign in to comment.