Skip to content

Commit

Permalink
test(api): cover another weird case
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Aug 12, 2024
1 parent ae000db commit a55aa9e
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions internal/api/cloudflare_waf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,28 @@ func TestDeleteWAFList(t *testing.T) {
type listItem = string

func mockListItem(listItem listItem) cloudflare.ListItem {
return cloudflare.ListItem{
ID: mockID(listItem, 0),
IP: &listItem,
Redirect: nil,
Hostname: nil,
ASN: nil,
Comment: "",
CreatedOn: nil,
ModifiedOn: nil,
if listItem == "" {
return cloudflare.ListItem{
ID: mockID(listItem, 0),
IP: nil,
Redirect: nil,
Hostname: nil,
ASN: nil,
Comment: "",
CreatedOn: nil,
ModifiedOn: nil,
}
} else {
return cloudflare.ListItem{
ID: mockID(listItem, 0),
IP: &listItem,
Redirect: nil,
Hostname: nil,
ASN: nil,
Comment: "",
CreatedOn: nil,
ModifiedOn: nil,
}
}
}

Expand Down Expand Up @@ -667,6 +680,17 @@ func TestListWAFListItems(t *testing.T) {
)
},
},
"nil": {
1,
[]listItem{""},
1,
false, nil,
func(ppfmt *mocks.MockPP) {
ppfmt.EXPECT().Warningf(pp.EmojiImpossible,
"Found a non-IP in the list %q (ID: %s)",
"list", mockID("list", 0))
},
},
} {
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit a55aa9e

Please sign in to comment.