Skip to content

Commit

Permalink
add TestHasPodStopped
Browse files Browse the repository at this point in the history
Signed-off-by: Fluder-Paradyne <[email protected]>
  • Loading branch information
Fluder-Paradyne committed Dec 23, 2024
1 parent f5fc479 commit d0e06c7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions server/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,38 @@ func TestLogsGetSelectedPod(t *testing.T) {
})
}

func TestHasPodStopped(t *testing.T) {
runningPod := appv1.ResourceNode{
ResourceRef: appsv1.ResourceRef{Group: "", Version: "v1", Kind: "Pod", Name: "pod", UID: "1"},
Info: []appsv1.InfoItem{{Name: "Status Reason", Value: "Running"}},
}
completedPod := appv1.ResourceNode{
ResourceRef: appsv1.ResourceRef{Group: "", Version: "v1", Kind: "Pod", Name: "pod", UID: "2"},
Info: []appsv1.InfoItem{{Name: "Status Reason", Value: "Completed"}},
}
failedPod := appv1.ResourceNode{
ResourceRef: appsv1.ResourceRef{Group: "", Version: "v1", Kind: "Pod", Name: "pod", UID: "3"},
Info: []appsv1.InfoItem{{Name: "Status Reason", Value: "Failed"}},
}
errorPod := appv1.ResourceNode{
ResourceRef: appsv1.ResourceRef{Group: "", Version: "v1", Kind: "Pod", Name: "pod", UID: "4"},
Info: []appsv1.InfoItem{{Name: "Status Reason", Value: "Error"}},
}

t.Run("RunningPod", func(t *testing.T) {
assert.False(t, hasPodStopped(runningPod))
})
t.Run("CompletedPod", func(t *testing.T) {
assert.True(t, hasPodStopped(completedPod))
})
t.Run("FailedPod", func(t *testing.T) {
assert.True(t, hasPodStopped(failedPod))
})
t.Run("ErrorPod", func(t *testing.T) {
assert.True(t, hasPodStopped(errorPod))
})
}

func TestMaxPodLogsRender(t *testing.T) {
defaultMaxPodLogsToRender, _ := newTestAppServer(t).settingsMgr.GetMaxPodLogsToRender()

Expand Down

0 comments on commit d0e06c7

Please sign in to comment.