Skip to content

Commit

Permalink
fix: handle non-nil fields in task wait (#422)
Browse files Browse the repository at this point in the history
Fixes #421 

Co-authored-by: NonlinearFruit <[email protected]>
  • Loading branch information
jameschensmith and NonlinearFruit authored Sep 20, 2024
1 parent f0125f4 commit 6d20dd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cmd/task/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func WaitRun(out io.Writer, taskIDs []string, getServerTasksCallback ServerTasks
if t.IsCompleted == nil || !*t.IsCompleted {
pendingTaskIDs = append(pendingTaskIDs, t.ID)
}
if t.FinishedSuccessfully != nil && !*t.FinishedSuccessfully {
if (t.IsCompleted != nil && *t.IsCompleted) && (t.FinishedSuccessfully != nil && !*t.FinishedSuccessfully) {
failedTaskIDs = append(failedTaskIDs, t.ID)
}
fmt.Fprintf(out, "%s: %s\n", t.Description, t.State)
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/task/wait/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ func TestWait(t *testing.T) {

taskList[0].ID = defaultTaskIDs[0]
taskList[0].IsCompleted = &boolFalse
taskList[0].FinishedSuccessfully = &boolFalse
taskList[0].Description = "Deploy Bar 1 release 0.0.2 to Foo"
taskList[0].State = "Executing"

taskList[1].ID = defaultTaskIDs[0]
taskList[1].IsCompleted = &boolTrue
taskList[1].FinishedSuccessfully = &boolTrue
taskList[1].Description = "Deploy Bar 2 release 0.0.2 to Foo"
taskList[1].State = "Success"

Expand All @@ -57,6 +59,7 @@ func TestWait(t *testing.T) {
assert.Len(t, taskIDs, 1)
assert.Equal(t, defaultTaskIDs[0], taskIDs[0])
taskList[0].IsCompleted = &boolTrue
taskList[0].FinishedSuccessfully = &boolTrue
taskList[0].State = "Success"
taskList = taskList[:len(taskList)-1]
return taskList, nil
Expand Down Expand Up @@ -121,6 +124,7 @@ func TestWait_FailedPendingTask(t *testing.T) {

taskList[0].ID = defaultTaskIDs[0]
taskList[0].IsCompleted = &boolFalse
taskList[0].FinishedSuccessfully = &boolFalse
taskList[0].Description = "Deploy Bar 1 release 0.0.2 to Foo"
taskList[0].State = "Executing"

Expand Down

0 comments on commit 6d20dd9

Please sign in to comment.