Skip to content

Commit

Permalink
fix: consider the case where deliveries can be an empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
shankiyani committed Dec 30, 2024
1 parent e268ca1 commit 776044d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ func (s *Server) handleRetry() http.Handler {
return
}

if len(deliveries) == 0 {
logger.InfoContext(ctx, "no deliveries from GitHub",
"cursor", cursor)
break
}

// in anticipation of the happy path, store the first event to advance the
// cursor
if firstCheckpoint == "" {
Expand Down
15 changes: 15 additions & 0 deletions pkg/retry/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ func TestHandleRetry(t *testing.T) {
listDeliveries: &listDeliveriesRes{err: errors.New("error")},
},
},
{
name: "github_list_deliveries_empty",
expStatusCode: http.StatusAccepted,
expRespBody: `{"status":"accepted"}`,
datastoreClientOverride: &MockDatastore{
retrieveCheckpointID: &retrieveCheckpointIDRes{res: "checkpoint-id"},
},
gcsLockClientOverride: &MockLock{
acquire: &acquireRes{},
},
githubOverride: &MockGitHub{
listDeliveries: &listDeliveriesRes{deliveries: []*github.HookDelivery{},

Check failure on line 140 in pkg/retry/retry_test.go

View workflow job for this annotation

GitHub Actions / go_lint / golangci

File is not `gofumpt`-ed with `-extra` (gofumpt)
res: &github.Response{}},
},
},
{
name: "github_redeliver_event_failure_big_query_entry_not_exists",
expStatusCode: http.StatusInternalServerError,
Expand Down

0 comments on commit 776044d

Please sign in to comment.