@@ -160,9 +160,9 @@ func hashResource(t *testing.T, resource types.Resource) string {
160
160
func TestLinearInitialResources (t * testing.T ) {
161
161
c := NewLinearCache (testType , WithInitialResources (map [string ]types.Resource {"a" : testResource ("a" ), "b" : testResource ("b" )}))
162
162
w := make (chan Response , 1 )
163
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType }, w )
163
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType }, w , nil )
164
164
verifyResponse (t , w , "0" , 1 )
165
- c .CreateWatch (& Request {TypeUrl : testType }, w )
165
+ c .CreateWatch (& Request {TypeUrl : testType }, w , nil )
166
166
verifyResponse (t , w , "0" , 2 )
167
167
}
168
168
@@ -174,7 +174,7 @@ func TestLinearCornerCases(t *testing.T) {
174
174
}
175
175
// create an incorrect type URL request
176
176
w := make (chan Response , 1 )
177
- c .CreateWatch (& Request {TypeUrl : "test" }, w )
177
+ c .CreateWatch (& Request {TypeUrl : "test" }, w , nil )
178
178
select {
179
179
case r := <- w :
180
180
if r != nil {
@@ -190,11 +190,11 @@ func TestLinearBasic(t *testing.T) {
190
190
191
191
// Create watches before a resource is ready
192
192
w1 := make (chan Response , 1 )
193
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w1 )
193
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w1 , nil )
194
194
mustBlock (t , w1 )
195
195
196
196
w := make (chan Response , 1 )
197
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w )
197
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w , nil )
198
198
mustBlock (t , w )
199
199
checkWatchCount (t , c , "a" , 2 )
200
200
checkWatchCount (t , c , "b" , 1 )
@@ -205,19 +205,19 @@ func TestLinearBasic(t *testing.T) {
205
205
verifyResponse (t , w , "1" , 1 )
206
206
207
207
// Request again, should get same response
208
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w )
208
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w , nil )
209
209
checkWatchCount (t , c , "a" , 0 )
210
210
verifyResponse (t , w , "1" , 1 )
211
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w )
211
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w , nil )
212
212
checkWatchCount (t , c , "a" , 0 )
213
213
verifyResponse (t , w , "1" , 1 )
214
214
215
215
// Add another element and update the first, response should be different
216
216
require .NoError (t , c .UpdateResource ("b" , testResource ("b" )))
217
217
require .NoError (t , c .UpdateResource ("a" , testResource ("aa" )))
218
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w )
218
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w , nil )
219
219
verifyResponse (t , w , "3" , 1 )
220
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w )
220
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w , nil )
221
221
verifyResponse (t , w , "3" , 2 )
222
222
}
223
223
@@ -226,10 +226,10 @@ func TestLinearSetResources(t *testing.T) {
226
226
227
227
// Create new resources
228
228
w1 := make (chan Response , 1 )
229
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w1 )
229
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w1 , nil )
230
230
mustBlock (t , w1 )
231
231
w2 := make (chan Response , 1 )
232
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w2 )
232
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w2 , nil )
233
233
mustBlock (t , w2 )
234
234
c .SetResources (map [string ]types.Resource {
235
235
"a" : testResource ("a" ),
@@ -239,9 +239,9 @@ func TestLinearSetResources(t *testing.T) {
239
239
verifyResponse (t , w2 , "1" , 2 ) // the version was only incremented once for all resources
240
240
241
241
// Add another element and update the first, response should be different
242
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "1" }, w1 )
242
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "1" }, w1 , nil )
243
243
mustBlock (t , w1 )
244
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w2 )
244
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w2 , nil )
245
245
mustBlock (t , w2 )
246
246
c .SetResources (map [string ]types.Resource {
247
247
"a" : testResource ("aa" ),
@@ -252,9 +252,9 @@ func TestLinearSetResources(t *testing.T) {
252
252
verifyResponse (t , w2 , "2" , 3 )
253
253
254
254
// Delete resource
255
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "2" }, w1 )
255
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "2" }, w1 , nil )
256
256
mustBlock (t , w1 )
257
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "2" }, w2 )
257
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "2" }, w2 , nil )
258
258
mustBlock (t , w2 )
259
259
c .SetResources (map [string ]types.Resource {
260
260
"b" : testResource ("b" ),
@@ -285,43 +285,43 @@ func TestLinearVersionPrefix(t *testing.T) {
285
285
c := NewLinearCache (testType , WithVersionPrefix ("instance1-" ))
286
286
287
287
w := make (chan Response , 1 )
288
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w )
288
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w , nil )
289
289
verifyResponse (t , w , "instance1-0" , 0 )
290
290
291
291
require .NoError (t , c .UpdateResource ("a" , testResource ("a" )))
292
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w )
292
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w , nil )
293
293
verifyResponse (t , w , "instance1-1" , 1 )
294
294
295
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "instance1-1" }, w )
295
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "instance1-1" }, w , nil )
296
296
mustBlock (t , w )
297
297
checkWatchCount (t , c , "a" , 1 )
298
298
}
299
299
300
300
func TestLinearDeletion (t * testing.T ) {
301
301
c := NewLinearCache (testType , WithInitialResources (map [string ]types.Resource {"a" : testResource ("a" ), "b" : testResource ("b" )}))
302
302
w := make (chan Response , 1 )
303
- c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w )
303
+ c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "0" }, w , nil )
304
304
mustBlock (t , w )
305
305
checkWatchCount (t , c , "a" , 1 )
306
306
require .NoError (t , c .DeleteResource ("a" ))
307
307
verifyResponse (t , w , "1" , 0 )
308
308
checkWatchCount (t , c , "a" , 0 )
309
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w )
309
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w , nil )
310
310
verifyResponse (t , w , "1" , 1 )
311
311
checkWatchCount (t , c , "b" , 0 )
312
312
require .NoError (t , c .DeleteResource ("b" ))
313
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w )
313
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w , nil )
314
314
verifyResponse (t , w , "2" , 0 )
315
315
checkWatchCount (t , c , "b" , 0 )
316
316
}
317
317
318
318
func TestLinearWatchTwo (t * testing.T ) {
319
319
c := NewLinearCache (testType , WithInitialResources (map [string ]types.Resource {"a" : testResource ("a" ), "b" : testResource ("b" )}))
320
320
w := make (chan Response , 1 )
321
- c .CreateWatch (& Request {ResourceNames : []string {"a" , "b" }, TypeUrl : testType , VersionInfo : "0" }, w )
321
+ c .CreateWatch (& Request {ResourceNames : []string {"a" , "b" }, TypeUrl : testType , VersionInfo : "0" }, w , nil )
322
322
mustBlock (t , w )
323
323
w1 := make (chan Response , 1 )
324
- c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w1 )
324
+ c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "0" }, w1 , nil )
325
325
mustBlock (t , w1 )
326
326
require .NoError (t , c .UpdateResource ("a" , testResource ("aa" )))
327
327
// should only get the modified resource
@@ -335,14 +335,14 @@ func TestLinearCancel(t *testing.T) {
335
335
336
336
// cancel watch-all
337
337
w := make (chan Response , 1 )
338
- cancel := c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w )
338
+ cancel := c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w , nil )
339
339
mustBlock (t , w )
340
340
checkWatchCount (t , c , "a" , 1 )
341
341
cancel ()
342
342
checkWatchCount (t , c , "a" , 0 )
343
343
344
344
// cancel watch for "a"
345
- cancel = c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "1" }, w )
345
+ cancel = c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "1" }, w , nil )
346
346
mustBlock (t , w )
347
347
checkWatchCount (t , c , "a" , 1 )
348
348
cancel ()
@@ -352,10 +352,10 @@ func TestLinearCancel(t *testing.T) {
352
352
w2 := make (chan Response , 1 )
353
353
w3 := make (chan Response , 1 )
354
354
w4 := make (chan Response , 1 )
355
- cancel = c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "1" }, w )
356
- cancel2 := c .CreateWatch (& Request {ResourceNames : []string {"b" }, TypeUrl : testType , VersionInfo : "1" }, w2 )
357
- cancel3 := c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w3 )
358
- cancel4 := c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w4 )
355
+ cancel = c .CreateWatch (& Request {ResourceNames : []string {"a" }, TypeUrl : testType , VersionInfo : "1" }, w , nil )
356
+ cancel2 := c .CreateWatch (& Request {ResourceNames : []string {"b" }, TypeUrl : testType , VersionInfo : "1" }, w2 , nil )
357
+ cancel3 := c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w3 , nil )
358
+ cancel4 := c .CreateWatch (& Request {TypeUrl : testType , VersionInfo : "1" }, w4 , nil )
359
359
mustBlock (t , w )
360
360
mustBlock (t , w2 )
361
361
mustBlock (t , w3 )
@@ -396,7 +396,7 @@ func TestLinearConcurrentSetWatch(t *testing.T) {
396
396
ResourceNames : []string {id , id2 },
397
397
VersionInfo : "0" ,
398
398
TypeUrl : testType ,
399
- }, value )
399
+ }, value , nil )
400
400
// wait until all updates apply
401
401
verifyResponse (t , value , "" , 1 )
402
402
}
0 commit comments