@@ -20,6 +20,7 @@ package handlers
20
20
import (
21
21
"context"
22
22
"errors"
23
+ "fmt"
23
24
"net/http"
24
25
"net/http/httptest"
25
26
"reflect"
@@ -376,6 +377,7 @@ func TestRedisNotificationReceiver(t *testing.T) {
376
377
}
377
378
type args struct {
378
379
conf config.SyncConfig
380
+ ctx context.Context
379
381
}
380
382
tests := []struct {
381
383
name string
@@ -384,14 +386,20 @@ func TestRedisNotificationReceiver(t *testing.T) {
384
386
}{
385
387
{
386
388
name : "Test happy path" ,
387
- args : args {conf : conf },
389
+ args : args {
390
+ conf : conf ,
391
+ ctx : context .WithValue (context .Background (), SDKKey , "random-sdk-key-1" ),
392
+ },
388
393
want : func (ctx context.Context ) (<- chan syncer.Event , error ) {
389
394
return make (<- chan syncer.Event ), nil
390
395
},
391
396
},
392
397
{
393
398
name : "Test empty config" ,
394
- args : args {conf : config.SyncConfig {}},
399
+ args : args {
400
+ conf : config.SyncConfig {},
401
+ ctx : context .WithValue (context .Background (), SDKKey , "random-sdk-key-2" ),
402
+ },
395
403
want : func (ctx context.Context ) (<- chan syncer.Event , error ) {
396
404
return nil , errors .New ("error" )
397
405
},
@@ -404,15 +412,16 @@ func TestRedisNotificationReceiver(t *testing.T) {
404
412
t .Errorf ("RedisNotificationReceiver() = %v, want %v" , got , tt .want )
405
413
}
406
414
407
- ch1 , err1 := got (context . TODO () )
408
- ch2 , err2 := tt .want (context . TODO () )
415
+ ch1 , err1 := got (tt . args . ctx )
416
+ ch2 , err2 := tt .want (tt . args . ctx )
409
417
410
418
if reflect .TypeOf (err1 ) != reflect .TypeOf (err2 ) {
419
+ fmt .Println (err1 , err2 )
411
420
t .Errorf ("error type not matched" )
412
421
}
413
422
414
423
if reflect .TypeOf (ch1 ) != reflect .TypeOf (ch2 ) {
415
- t .Errorf ("error type not matched" )
424
+ t .Errorf ("channel type not matched" )
416
425
}
417
426
})
418
427
}
0 commit comments