@@ -29,9 +29,10 @@ import (
29
29
)
30
30
31
31
var (
32
- testGVR = schema.GroupVersionResource {Group : "argoproj.io" , Resource : "applications" , Version : "v1alpha1" }
33
- testNamespace = "default"
34
- logEntry = logrus .NewEntry (logrus .New ())
32
+ testGVR = schema.GroupVersionResource {Group : "argoproj.io" , Resource : "applications" , Version : "v1alpha1" }
33
+ testNamespace = "default"
34
+ logEntry = logrus .NewEntry (logrus .New ())
35
+ notifiedAnnotationKey = subscriptions .NotifiedAnnotationKey ()
35
36
)
36
37
37
38
func mustToJson (val interface {}) string {
@@ -120,7 +121,7 @@ func TestSendsNotificationIfTriggered(t *testing.T) {
120
121
121
122
assert .NoError (t , err )
122
123
123
- state := NewState (annotations [NotifiedAnnotationKey ])
124
+ state := NewState (annotations [notifiedAnnotationKey ])
124
125
assert .NotNil (t , state [StateItemKey ("mock" , triggers.ConditionResult {}, services.Destination {Service : "mock" , Recipient : "recipient" })])
125
126
assert .Equal (t , app .Object , receivedObj )
126
127
}
@@ -132,7 +133,7 @@ func TestDoesNotSendNotificationIfAnnotationPresent(t *testing.T) {
132
133
_ = state .SetAlreadyNotified ("my-trigger" , triggers.ConditionResult {}, services.Destination {Service : "mock" , Recipient : "recipient" }, true )
133
134
app := newResource ("test" , withAnnotations (map [string ]string {
134
135
subscriptions .SubscribeAnnotationKey ("my-trigger" , "mock" ): "recipient" ,
135
- NotifiedAnnotationKey : mustToJson (state ),
136
+ notifiedAnnotationKey : mustToJson (state ),
136
137
}))
137
138
ctrl , api , err := newController (t , ctx , newFakeClient (app ))
138
139
assert .NoError (t , err )
@@ -154,7 +155,7 @@ func TestRemovesAnnotationIfNoTrigger(t *testing.T) {
154
155
_ = state .SetAlreadyNotified ("my-trigger" , triggers.ConditionResult {}, services.Destination {Service : "mock" , Recipient : "recipient" }, true )
155
156
app := newResource ("test" , withAnnotations (map [string ]string {
156
157
subscriptions .SubscribeAnnotationKey ("my-trigger" , "mock" ): "recipient" ,
157
- NotifiedAnnotationKey : mustToJson (state ),
158
+ notifiedAnnotationKey : mustToJson (state ),
158
159
}))
159
160
ctrl , api , err := newController (t , ctx , newFakeClient (app ))
160
161
assert .NoError (t , err )
@@ -166,7 +167,7 @@ func TestRemovesAnnotationIfNoTrigger(t *testing.T) {
166
167
logEntry .Errorf ("Failed to process: %v" , err )
167
168
}
168
169
assert .NoError (t , err )
169
- state = NewState (annotations [NotifiedAnnotationKey ])
170
+ state = NewState (annotations [notifiedAnnotationKey ])
170
171
assert .Empty (t , state )
171
172
}
172
173
@@ -179,7 +180,7 @@ func TestUpdatedAnnotationsSavedAsPatch(t *testing.T) {
179
180
180
181
app := newResource ("test" , withAnnotations (map [string ]string {
181
182
subscriptions .SubscribeAnnotationKey ("my-trigger" , "mock" ): "recipient" ,
182
- NotifiedAnnotationKey : mustToJson (state ),
183
+ notifiedAnnotationKey : mustToJson (state ),
183
184
}))
184
185
185
186
patchCh := make (chan []byte )
@@ -202,7 +203,7 @@ func TestUpdatedAnnotationsSavedAsPatch(t *testing.T) {
202
203
patch := map [string ]interface {}{}
203
204
err = json .Unmarshal (patchData , & patch )
204
205
assert .NoError (t , err )
205
- val , ok , err := unstructured .NestedFieldNoCopy (patch , "metadata" , "annotations" , NotifiedAnnotationKey )
206
+ val , ok , err := unstructured .NestedFieldNoCopy (patch , "metadata" , "annotations" , notifiedAnnotationKey )
206
207
assert .NoError (t , err )
207
208
assert .True (t , ok )
208
209
assert .Nil (t , val )
0 commit comments