@@ -16,19 +16,21 @@ func TestControllerRun(t *testing.T) {
1616
1717 // test adding the an egress config.
1818 ctx , cancel := context .WithCancel (context .Background ())
19- go controller .Run (ctx )
20-
21- configsChan <- provider.EgressConfig {
22- Resource : provider.Resource {
23- Name : "a" ,
24- Namespace : "x" ,
25- },
26- IPAddresses : map [string ]struct {}{
27- "10.0.0.1" : struct {}{},
28- },
29- }
30-
31- cancel ()
19+
20+ go func () {
21+ configsChan <- provider.EgressConfig {
22+ Resource : provider.Resource {
23+ Name : "a" ,
24+ Namespace : "x" ,
25+ },
26+ IPAddresses : map [string ]struct {}{
27+ "10.0.0.1" : struct {}{},
28+ },
29+ }
30+ cancel ()
31+ }()
32+ controller .Run (ctx )
33+
3234 require .Len (t , controller .configsCache , 1 )
3335 require .Contains (t , controller .configsCache , provider.Resource {
3436 Name : "a" ,
@@ -37,15 +39,17 @@ func TestControllerRun(t *testing.T) {
3739
3840 // test removing the config
3941 ctx , cancel = context .WithCancel (context .Background ())
40- go controller .Run (ctx )
4142
42- configsChan <- provider.EgressConfig {
43- Resource : provider.Resource {
44- Name : "a" ,
45- Namespace : "x" ,
46- },
47- }
43+ go func () {
44+ configsChan <- provider.EgressConfig {
45+ Resource : provider.Resource {
46+ Name : "a" ,
47+ Namespace : "x" ,
48+ },
49+ }
50+ cancel ()
51+ }()
52+ controller .Run (ctx )
4853
49- cancel ()
5054 require .Len (t , controller .configsCache , 0 )
5155}
0 commit comments