Skip to content

Commit

Permalink
Missing test coverage - add test case non-terminal-timing-out
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Dec 14, 2023
1 parent 625ab3d commit e50ebb8
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions flytepropeller/pkg/apis/flyteworkflow/v1alpha1/node_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestNodeStatus_UpdatePhase(t *testing.T) {
ns := NodeStatus{}
p := NodePhaseRunning
msg := "running"
ns.UpdatePhase(p, n, msg, false, nil)
ns.UpdatePhase(p, n, msg, clearStateOnAnyTermination, nil)

assert.Equal(t, *ns.LastUpdatedAt, n)
assert.Nil(t, ns.QueuedAt)
Expand All @@ -312,11 +312,27 @@ func TestNodeStatus_UpdatePhase(t *testing.T) {
assert.Nil(t, ns.Error)
})

t.Run("non-terminal-timing-out", func(t *testing.T) {
ns := NodeStatus{}
p := NodePhaseTimingOut
msg := "timing-out"
ns.UpdatePhase(p, n, msg, clearStateOnAnyTermination, nil)

assert.Equal(t, *ns.LastUpdatedAt, n)
assert.Nil(t, ns.QueuedAt)
assert.Nil(t, ns.LastAttemptStartedAt)
assert.Nil(t, ns.StartedAt)
assert.Nil(t, ns.StoppedAt)
assert.Equal(t, p, ns.Phase)
assert.Equal(t, msg, ns.Message)
assert.Nil(t, ns.Error)
})

t.Run("terminal-success", func(t *testing.T) {
ns := NodeStatus{}
p := NodePhaseSucceeded
msg := success
ns.UpdatePhase(p, n, msg, false, nil)
ns.UpdatePhase(p, n, msg, clearStateOnAnyTermination, nil)

assert.Nil(t, ns.LastUpdatedAt)
assert.Nil(t, ns.QueuedAt)
Expand All @@ -332,7 +348,7 @@ func TestNodeStatus_UpdatePhase(t *testing.T) {
ns := NodeStatus{}
p := NodePhaseSucceeded
msg := success
ns.UpdatePhase(p, n, msg, false, nil)
ns.UpdatePhase(p, n, msg, clearStateOnAnyTermination, nil)

assert.Nil(t, ns.LastUpdatedAt)
assert.Nil(t, ns.QueuedAt)
Expand All @@ -358,7 +374,7 @@ func TestNodeStatus_UpdatePhase(t *testing.T) {
}
p := NodePhaseSucceeded
msg := success
ns.UpdatePhase(p, n, msg, false, nil)
ns.UpdatePhase(p, n, msg, clearStateOnAnyTermination, nil)

assert.Nil(t, ns.LastUpdatedAt)
assert.Nil(t, ns.QueuedAt)
Expand Down Expand Up @@ -390,7 +406,7 @@ func TestNodeStatus_UpdatePhase(t *testing.T) {
n2 := metav1.NewTime(time.Now())
p := NodePhaseRunning
msg := "running"
ns.UpdatePhase(p, n2, msg, false, nil)
ns.UpdatePhase(p, n2, msg, clearStateOnAnyTermination, nil)

assert.Equal(t, *ns.LastUpdatedAt, n2)
assert.Equal(t, *ns.QueuedAt, n)
Expand Down

0 comments on commit e50ebb8

Please sign in to comment.