@@ -347,6 +347,7 @@ func createRayHeadPodWithPhaseAndCondition(phase corev1.PodPhase, status corev1.
347347 {
348348 Type : corev1 .PodReady ,
349349 Status : status ,
350+ Reason : ContainersNotReady ,
350351 },
351352 },
352353 },
@@ -979,16 +980,19 @@ func TestFindHeadPodReadyCondition(t *testing.T) {
979980
980981func TestFindHeadPodReadyMessage (t * testing.T ) {
981982 tests := []struct {
982- name string
983- message string
984- expectedMessage string
985- status []corev1.ContainerStatus
983+ name string
984+ message string
985+ wantMessage string
986+ wantReason string
987+ status []corev1.ContainerStatus
986988 }{{
987- name : "no message no status want nothing" ,
989+ name : "no message no status want original reason" ,
990+ wantReason : ContainersNotReady ,
988991 }, {
989- name : "only reason" ,
990- message : "TooEarlyInTheMorning" ,
991- expectedMessage : "TooEarlyInTheMorning" ,
992+ name : "no container status want original reason" ,
993+ message : "TooEarlyInTheMorning" ,
994+ wantMessage : "TooEarlyInTheMorning" ,
995+ wantReason : ContainersNotReady ,
992996 }, {
993997 name : "one reason one status" ,
994998 message : "containers not ready" ,
@@ -1001,9 +1005,10 @@ func TestFindHeadPodReadyMessage(t *testing.T) {
10011005 },
10021006 },
10031007 }},
1004- expectedMessage : `containers not ready; ray: ImagePullBackOff: Back-off pulling image royproject/roy:latest: ErrImagePull: rpc error: code = NotFound` ,
1008+ wantReason : "ImagePullBackOff" ,
1009+ wantMessage : `containers not ready; ray: Back-off pulling image royproject/roy:latest: ErrImagePull: rpc error: code = NotFound` ,
10051010 }, {
1006- name : "one reason two statuses" ,
1011+ name : "one reason two statuses only copy first " ,
10071012 message : "aesthetic problems" ,
10081013 status : []corev1.ContainerStatus {{
10091014 Name : "indigo" ,
@@ -1022,7 +1027,8 @@ func TestFindHeadPodReadyMessage(t *testing.T) {
10221027 },
10231028 },
10241029 }},
1025- expectedMessage : "aesthetic problems; indigo: BadColor: too blue, circle: BadGeometry: too round" ,
1030+ wantReason : "BadColor" ,
1031+ wantMessage : "aesthetic problems; indigo: too blue" ,
10261032 }, {
10271033 name : "no reason one status" ,
10281034 status : []corev1.ContainerStatus {{
@@ -1034,7 +1040,8 @@ func TestFindHeadPodReadyMessage(t *testing.T) {
10341040 },
10351041 },
10361042 }},
1037- expectedMessage : "my-image: Crashed: bash not found" ,
1043+ wantReason : "Crashed" ,
1044+ wantMessage : "my-image: bash not found" ,
10381045 }}
10391046
10401047 for _ , tc := range tests {
@@ -1043,8 +1050,11 @@ func TestFindHeadPodReadyMessage(t *testing.T) {
10431050 pod .Status .Conditions [0 ].Message = tc .message
10441051 pod .Status .ContainerStatuses = tc .status
10451052 cond := FindHeadPodReadyCondition (pod )
1046- if cond .Message != tc .expectedMessage {
1047- t .Errorf ("FindHeadPodReadyCondition(...) returned condition with message %q, but wanted %q" , cond .Message , tc .expectedMessage )
1053+ if cond .Message != tc .wantMessage {
1054+ t .Errorf ("FindHeadPodReadyCondition(...) returned condition with message %q, but wanted %q" , cond .Message , tc .wantMessage )
1055+ }
1056+ if cond .Reason != tc .wantReason {
1057+ t .Errorf ("FindHeadPodReadyCondition(...) returned condition with reason %q, but wanted %q" , cond .Reason , tc .wantReason )
10481058 }
10491059 })
10501060 }
0 commit comments