From 6d20dd98a90d6c53d8ce8dffa284ba2fbc191816 Mon Sep 17 00:00:00 2001 From: James Chen-Smith Date: Thu, 19 Sep 2024 23:27:47 -0500 Subject: [PATCH] fix: handle non-nil fields in task wait (#422) Fixes #421 Co-authored-by: NonlinearFruit <1123benji5813@gmail.com> --- pkg/cmd/task/wait/wait.go | 2 +- pkg/cmd/task/wait/wait_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/task/wait/wait.go b/pkg/cmd/task/wait/wait.go index ee62feea..3fe86cec 100644 --- a/pkg/cmd/task/wait/wait.go +++ b/pkg/cmd/task/wait/wait.go @@ -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) diff --git a/pkg/cmd/task/wait/wait_test.go b/pkg/cmd/task/wait/wait_test.go index 06d73b53..84c86abb 100644 --- a/pkg/cmd/task/wait/wait_test.go +++ b/pkg/cmd/task/wait/wait_test.go @@ -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" @@ -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 @@ -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"