@@ -21,10 +21,13 @@ import (
21
21
"time"
22
22
23
23
"github.com/onsi/gomega"
24
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
25
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
25
26
"sigs.k8s.io/controller-runtime/pkg/client"
26
27
"sigs.k8s.io/controller-runtime/pkg/event"
27
28
29
+ "github.com/fluxcd/pkg/apis/meta"
30
+
28
31
sourcev1 "github.com/fluxcd/source-controller/api/v1"
29
32
)
30
33
@@ -46,6 +49,54 @@ func TestSourceRevisionChangePredicate_Update(t *testing.T) {
46
49
{name : "old with artifact" , old : sourceA , new : emptySource , want : false },
47
50
{name : "old not a source" , old : notASource , new : sourceA , want : false },
48
51
{name : "new not a source" , old : sourceA , new : notASource , want : false },
52
+ {
53
+ name : "old not ready and new ready" ,
54
+ old : & sourceMock {
55
+ revision : "revision-a" ,
56
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionFalse }},
57
+ },
58
+ new : & sourceMock {
59
+ revision : "revision-a" ,
60
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionTrue }},
61
+ },
62
+ want : true ,
63
+ },
64
+ {
65
+ name : "old ready and new not ready" ,
66
+ old : & sourceMock {
67
+ revision : "revision-a" ,
68
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionTrue }},
69
+ },
70
+ new : & sourceMock {
71
+ revision : "revision-a" ,
72
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionFalse }},
73
+ },
74
+ want : false ,
75
+ },
76
+ {
77
+ name : "old not ready and new not ready" ,
78
+ old : & sourceMock {
79
+ revision : "revision-a" ,
80
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionFalse }},
81
+ },
82
+ new : & sourceMock {
83
+ revision : "revision-a" ,
84
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionFalse }},
85
+ },
86
+ want : false ,
87
+ },
88
+ {
89
+ name : "old ready and new ready" ,
90
+ old : & sourceMock {
91
+ revision : "revision-a" ,
92
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionTrue }},
93
+ },
94
+ new : & sourceMock {
95
+ revision : "revision-a" ,
96
+ conditions : []metav1.Condition {{Type : meta .ReadyCondition , Status : metav1 .ConditionTrue }},
97
+ },
98
+ want : false ,
99
+ },
49
100
{name : "old nil" , old : nil , new : sourceA , want : false },
50
101
{name : "new nil" , old : sourceA , new : nil , want : false },
51
102
}
@@ -65,7 +116,8 @@ func TestSourceRevisionChangePredicate_Update(t *testing.T) {
65
116
66
117
type sourceMock struct {
67
118
unstructured.Unstructured
68
- revision string
119
+ revision string
120
+ conditions []metav1.Condition
69
121
}
70
122
71
123
func (m sourceMock ) GetRequeueAfter () time.Duration {
@@ -80,3 +132,7 @@ func (m *sourceMock) GetArtifact() *sourcev1.Artifact {
80
132
}
81
133
return nil
82
134
}
135
+
136
+ func (m * sourceMock ) GetConditions () []metav1.Condition {
137
+ return m .conditions
138
+ }
0 commit comments