Skip to content

Commit 2e1e048

Browse files
committed
Honor --page as start page when combined with --all
`webhook list --all --page N` previously dropped the page param when --all was set, causing GetAll to start at page 1 instead of page N. The legacy client's GetWithPagination preserved the start page when paging through all results; the migration regressed this. Fixed by appending the page param to the path before invoking GetAll. Added a unit test to lock in the behavior.
1 parent cd13197 commit 2e1e048

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

internal/commands/webhook.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ var webhookListCmd = &cobra.Command{
5757
switch {
5858
case webhookListAll:
5959
path := fmt.Sprintf("/boards/%s/webhooks.json", boardID)
60+
if webhookListPage > 0 {
61+
path += fmt.Sprintf("?page=%d", webhookListPage)
62+
}
6063
pages, err := ac.GetAll(cmd.Context(), path)
6164
if err != nil {
6265
return convertSDKError(err)

internal/commands/webhook_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@ func TestWebhookList(t *testing.T) {
8585
t.Errorf("expected path with page=3, got '%s'", got)
8686
}
8787
})
88+
89+
t.Run("--all honors --page as the start page", func(t *testing.T) {
90+
mock := NewMockClient()
91+
mock.GetWithPaginationResponse = &client.APIResponse{
92+
StatusCode: 200,
93+
Data: []any{},
94+
}
95+
96+
SetTestModeWithSDK(mock)
97+
SetTestConfig("token", "account", "https://api.example.com")
98+
defer resetTest()
99+
100+
webhookListBoard = "board-1"
101+
webhookListPage = 2
102+
webhookListAll = true
103+
err := webhookListCmd.RunE(webhookListCmd, []string{})
104+
webhookListBoard = ""
105+
webhookListPage = 0
106+
webhookListAll = false
107+
108+
assertExitCode(t, err, 0)
109+
if got := mock.GetWithPaginationCalls[0].Path; got != "/boards/board-1/webhooks.json?page=2" {
110+
t.Errorf("expected --all to start from --page=2, got '%s'", got)
111+
}
112+
})
88113
}
89114

90115
func TestWebhookDeliveries(t *testing.T) {

0 commit comments

Comments
 (0)