@@ -26,11 +26,7 @@ import (
26
26
27
27
var _ watch.Interface = & multiWatch {}
28
28
29
- func setupMultiWatch (n int , t * testing.T , rvs ... string ) ([]* watch.FakeWatcher , * multiWatch ) {
30
- // Default resource versions to the correct length if none were passed.
31
- if len (rvs ) == 0 {
32
- rvs = make ([]string , n )
33
- }
29
+ func setupMultiWatch (n int , t * testing.T , rvs string ) ([]* watch.FakeWatcher , * multiWatch ) {
34
30
ws := make ([]* watch.FakeWatcher , n )
35
31
lws := make ([]cache.ListerWatcher , n )
36
32
for i := range ws {
@@ -48,28 +44,19 @@ func setupMultiWatch(n int, t *testing.T, rvs ...string) ([]*watch.FakeWatcher,
48
44
}
49
45
50
46
func TestNewMultiWatch (t * testing.T ) {
51
- func () {
52
- defer func () {
53
- if r := recover (); r == nil {
54
- t .Error ("expected newMultiWatch to panic when number of resource versions is less than ListerWatchers" )
55
- }
56
- }()
57
- // Create a multiWatch from 2 ListerWatchers but only pass 1 resource version.
58
- _ , _ = setupMultiWatch (2 , t , "1" )
59
- }()
60
47
func () {
61
48
defer func () {
62
49
if r := recover (); r != nil {
63
50
t .Errorf ("newMultiWatch should not panic when number of resource versions matches ListerWatchers; got: %v" , r )
64
51
}
65
52
}()
66
- // Create a multiWatch from 2 ListerWatchers and pass 2 resource versions.
67
- _ , _ = setupMultiWatch (2 , t , "1" , "2 " )
53
+ // Create a multiWatch from 1 ListerWatchers and pass 1 resource versions.
54
+ _ , _ = setupMultiWatch (1 , t , "1" )
68
55
}()
69
56
}
70
57
71
58
func TestMultiWatchResultChan (t * testing.T ) {
72
- ws , m := setupMultiWatch (10 , t )
59
+ ws , m := setupMultiWatch (10 , t , "10" )
73
60
defer m .Stop ()
74
61
var events []watch.Event
75
62
var wg sync.WaitGroup
@@ -97,7 +84,7 @@ func TestMultiWatchResultChan(t *testing.T) {
97
84
}
98
85
99
86
func TestMultiWatchStop (t * testing.T ) {
100
- ws , m := setupMultiWatch (10 , t )
87
+ ws , m := setupMultiWatch (10 , t , "10" )
101
88
m .Stop ()
102
89
var stopped int
103
90
for _ , w := range ws {
@@ -149,7 +136,7 @@ func TestRacyMultiWatch(t *testing.T) {
149
136
150
137
mw , err := newMultiWatch (
151
138
[]cache.ListerWatcher {lw },
152
- [] string { "foo" } ,
139
+ "foo" ,
153
140
metav1.ListOptions {},
154
141
)
155
142
if err != nil {
0 commit comments