Skip to content

Commit f438b56

Browse files
committed
clarify unknown cases
1 parent 4bcd152 commit f438b56

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

models/actions/run_job.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,12 @@ func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, col
155155
func AggregateJobStatus(jobs []*ActionRunJob) Status {
156156
allSuccessOrSkipped := len(jobs) != 0
157157
allSkipped := len(jobs) != 0
158-
var hasFailure, hasCancelled, hasSkipped, hasWaiting, hasRunning, hasBlocked bool
158+
var hasFailure, hasCancelled, hasWaiting, hasRunning, hasBlocked bool
159159
for _, job := range jobs {
160160
allSuccessOrSkipped = allSuccessOrSkipped && (job.Status == StatusSuccess || job.Status == StatusSkipped)
161161
allSkipped = allSkipped && job.Status == StatusSkipped
162162
hasFailure = hasFailure || job.Status == StatusFailure
163163
hasCancelled = hasCancelled || job.Status == StatusCancelled
164-
hasSkipped = hasSkipped || job.Status == StatusSkipped
165164
hasWaiting = hasWaiting || job.Status == StatusWaiting
166165
hasRunning = hasRunning || job.Status == StatusRunning
167166
hasBlocked = hasBlocked || job.Status == StatusBlocked
@@ -181,8 +180,6 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status {
181180
return StatusWaiting
182181
case hasBlocked:
183182
return StatusBlocked
184-
case hasSkipped:
185-
return StatusSkipped
186183
default:
187184
return StatusUnknown // it shouldn't happen
188185
}

models/actions/run_job_status_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ func TestAggregateJobStatus(t *testing.T) {
3030
statuses []Status
3131
expected Status
3232
}{
33-
// empty, maybe it shouldn't happen in real world
33+
// unknown cases, maybe it shouldn't happen in real world
3434
{[]Status{}, StatusUnknown},
35+
{[]Status{StatusUnknown, StatusSuccess}, StatusUnknown},
36+
{[]Status{StatusUnknown, StatusSkipped}, StatusUnknown},
37+
{[]Status{StatusUnknown, StatusFailure}, StatusFailure},
38+
{[]Status{StatusUnknown, StatusCancelled}, StatusCancelled},
39+
{[]Status{StatusUnknown, StatusWaiting}, StatusWaiting},
40+
{[]Status{StatusUnknown, StatusRunning}, StatusRunning},
41+
{[]Status{StatusUnknown, StatusBlocked}, StatusBlocked},
3542

3643
// success with other status
3744
{[]Status{StatusSuccess}, StatusSuccess},

0 commit comments

Comments
 (0)