Skip to content

Commit 23e29c6

Browse files
committed
test(secret_scanning): pagination expectations + new test case (github#2363)
1 parent 063349a commit 23e29c6

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

‎pkg/github/secret_scanning_test.go‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ func Test_ListSecretScanningAlerts(t *testing.T) {
165165
name: "successful resolved alerts listing",
166166
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
167167
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
168-
"state": "resolved",
168+
"state": "resolved",
169+
"page": "1",
170+
"per_page": "30",
169171
}).andThen(
170172
mockResponse(t, http.StatusOK, []*github.SecretScanningAlert{&resolvedAlert}),
171173
),
@@ -181,7 +183,10 @@ func Test_ListSecretScanningAlerts(t *testing.T) {
181183
{
182184
name: "successful alerts listing",
183185
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
184-
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{}).andThen(
186+
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
187+
"page": "1",
188+
"per_page": "30",
189+
}).andThen(
185190
mockResponse(t, http.StatusOK, []*github.SecretScanningAlert{&resolvedAlert, &openAlert}),
186191
),
187192
}),
@@ -192,6 +197,25 @@ func Test_ListSecretScanningAlerts(t *testing.T) {
192197
expectError: false,
193198
expectedAlerts: []*github.SecretScanningAlert{&resolvedAlert, &openAlert},
194199
},
200+
{
201+
name: "successful alerts listing with custom pagination",
202+
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
203+
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
204+
"page": "2",
205+
"per_page": "50",
206+
}).andThen(
207+
mockResponse(t, http.StatusOK, []*github.SecretScanningAlert{&openAlert}),
208+
),
209+
}),
210+
requestArgs: map[string]any{
211+
"owner": "owner",
212+
"repo": "repo",
213+
"page": float64(2),
214+
"perPage": float64(50),
215+
},
216+
expectError: false,
217+
expectedAlerts: []*github.SecretScanningAlert{&openAlert},
218+
},
195219
{
196220
name: "alerts listing fails",
197221
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{

0 commit comments

Comments
 (0)