@@ -4,29 +4,39 @@ import (
44 . "github.com/onsi/ginkgo"
55 . "github.com/onsi/gomega"
66 corev1 "k8s.io/api/core/v1"
7- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
87)
98
109var _ = Describe ("Conditions" , func () {
11- Context ("Ready" , func () {
10+ Describe ("Ready" , func () {
1211 It ("returns 'Ready' condition set to true" , func () {
13- c := Ready ()
12+ c := Ready (nil )
1413 Expect (string (c .Type )).To (Equal ("Ready" ))
1514 Expect (c .Status ).To (Equal (corev1 .ConditionTrue ))
1615 Expect (c .Reason ).To (Equal ("SuccessfulCreateOrUpdate" ))
17- Expect (c .LastTransitionTime ). NotTo ( Equal (metav1. Time {})) // has been set; not empty
16+ Expect (c .LastTransitionTime . IsZero ()). To ( BeFalse ())
1817 })
19-
2018 })
21-
22- Context ("NotReady" , func () {
19+ Describe ("NotReady" , func () {
2320 It ("returns 'Ready' condition set to false" , func () {
24- c := NotReady ("fail to declare queue" )
21+ c := NotReady ("fail to declare queue" , nil )
2522 Expect (string (c .Type )).To (Equal ("Ready" ))
2623 Expect (c .Status ).To (Equal (corev1 .ConditionFalse ))
2724 Expect (c .Reason ).To (Equal ("FailedCreateOrUpdate" ))
2825 Expect (c .Message ).To (Equal ("fail to declare queue" ))
29- Expect (c .LastTransitionTime ).NotTo (Equal (metav1.Time {})) // has been set; not empty
26+ Expect (c .LastTransitionTime .IsZero ()).To (BeFalse ())
27+ })
28+ })
29+ Context ("LastTransitionTime" , func () {
30+ It ("changes only if status changes" , func () {
31+ c1 := Ready (nil )
32+ Expect (c1 .LastTransitionTime .IsZero ()).To (BeFalse ())
33+ c2 := Ready ([]Condition {
34+ Condition {Type : "I'm some other type" },
35+ c1 ,
36+ })
37+ Expect (c2 .LastTransitionTime .Time ).To (BeTemporally ("==" , c1 .LastTransitionTime .Time ))
38+ c3 := NotReady ("some message" , []Condition {c2 })
39+ Expect (c3 .LastTransitionTime .Time ).To (BeTemporally (">" , c2 .LastTransitionTime .Time ))
3040 })
3141 })
3242})
0 commit comments