44package controllers
55
66import (
7- "context"
87 "testing"
98
109 "github.com/stretchr/testify/assert"
@@ -18,29 +17,21 @@ func TestEventWatcherRegistry(t *testing.T) {
1817 registry := newEventWatcherRegistry ()
1918 assert .Equal (t , 0 , registry .registry .ItemCount ())
2019
21- ctx , cancel := context .WithCancel (context .Background ())
22- stoppedCh := make (chan struct {}, 1 )
23-
24- // Create a new event watcher metadata
20+ // Create a new event subscription metadata
2521 meta := & eventWatcherMeta {
2622 LastGeneration : 123 ,
2723 LastClientID : "client-id" ,
28- Cancel : cancel ,
29- StoppedCh : stoppedCh ,
3024 }
3125
32- // Register the event watcher
26+ // Register the event subscription
3327 itemName := types.NamespacedName {Name : "test" , Namespace : "default" }
3428 registry .Register (itemName , meta )
3529 assert .Equal (t , 1 , registry .registry .ItemCount ())
3630
37- // close the channel
38- close (stoppedCh )
39-
40- // Get the event watcher
31+ // Get the event subscription metadata
4132 got , ok := registry .Get (itemName )
42- require .True (t , ok , "expected to get event watcher , got none" )
43- require .NotNil (t , got , "expected to get event watcher , got nil" )
33+ require .True (t , ok , "expected to get event subscription metadata , got none" )
34+ require .NotNil (t , got , "expected to get event subscription metadata , got nil" )
4435
4536 assert .Equal (t , int64 (123 ), got .LastGeneration )
4637 assert .Equal (t , "client-id" , got .LastClientID )
@@ -52,25 +43,18 @@ func TestEventWatcherRegistry(t *testing.T) {
5243
5344 // Get again
5445 gotAgain , ok := registry .Get (itemName )
55- require .True (t , ok , "expected to get event watcher again, got none" )
56- require .NotNil (t , gotAgain , "expected to get event watcher again, got nil" )
46+ require .True (t , ok , "expected to get event subscription metadata again, got none" )
47+ require .NotNil (t , gotAgain , "expected to get event subscription metadata again, got nil" )
5748
5849 assert .Equal (t , int64 (456 ), gotAgain .LastGeneration )
5950 assert .Equal (t , "client-id" , gotAgain .LastClientID )
6051
61- // Cancel context received from the registry, check the original
62- gotAgain .Cancel ()
63- assert .Equal (t , ctx .Err (), context .Canceled )
64-
65- _ , isOpen := <- gotAgain .StoppedCh
66- assert .False (t , isOpen , "expected stoppedCh from registry item to be closed" )
67-
68- // Delete the event watcher
52+ // Delete the event subscription
6953 registry .Delete (itemName )
7054 assert .Equal (t , 0 , registry .registry .ItemCount ())
7155
72- // Get the event watcher
56+ // Get the event subscription metadata
7357 gotFinally , ok := registry .Get (itemName )
74- assert .False (t , ok , "expected to not get event watcher , got one" )
75- assert .Nil (t , gotFinally , "expected nil event watcher " )
58+ assert .False (t , ok , "expected to not get event subscription metadata , got one" )
59+ assert .Nil (t , gotFinally , "expected nil event subscription metadata " )
7660}
0 commit comments