Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions cmd/review-goose/filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,66 @@ func TestExtractOrgFromRepo(t *testing.T) {
})
}
}

// TestIsAlreadyTrackedAsBlocked tests that sprinkler correctly identifies blocked PRs
func TestIsAlreadyTrackedAsBlocked(t *testing.T) {
app := &App{
incoming: []PR{
{URL: "https://github.com/org1/repo1/pull/1", IsBlocked: true},
{URL: "https://github.com/org1/repo1/pull/2", IsBlocked: false},
{URL: "https://github.com/org1/repo1/pull/3", NeedsReview: true, IsBlocked: false}, // NeedsReview but not IsBlocked
},
outgoing: []PR{
{URL: "https://github.com/org2/repo2/pull/10", IsBlocked: true},
{URL: "https://github.com/org2/repo2/pull/11", IsBlocked: false},
},
}

sm := &sprinklerMonitor{app: app}

tests := []struct {
name string
url string
want bool
}{
{
name: "incoming PR is blocked",
url: "https://github.com/org1/repo1/pull/1",
want: true,
},
{
name: "incoming PR is not blocked",
url: "https://github.com/org1/repo1/pull/2",
want: false,
},
{
name: "incoming PR needs review but is not blocked",
url: "https://github.com/org1/repo1/pull/3",
want: false,
},
{
name: "outgoing PR is blocked",
url: "https://github.com/org2/repo2/pull/10",
want: true,
},
{
name: "outgoing PR is not blocked",
url: "https://github.com/org2/repo2/pull/11",
want: false,
},
{
name: "unknown PR",
url: "https://github.com/org3/repo3/pull/99",
want: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := sm.isAlreadyTrackedAsBlocked(tt.url, "test", 1)
if got != tt.want {
t.Errorf("isAlreadyTrackedAsBlocked(%q) = %v, want %v", tt.url, got, tt.want)
}
})
}
}
1 change: 1 addition & 0 deletions cmd/review-goose/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func (app *App) fetchTurnDataSync(ctx context.Context, issues []*github.Issue, u
continue
}
(*incoming)[i].NeedsReview = needsReview
(*incoming)[i].IsBlocked = isBlocked
(*incoming)[i].ActionReason = actionReason
(*incoming)[i].ActionKind = actionKind
(*incoming)[i].TestState = testState
Expand Down