@@ -132,22 +132,22 @@ func TestWithNodesPodLocked(t *testing.T) {
132
132
Available : true ,
133
133
}
134
134
// failed by list nodes
135
- store .On ("GetNodesByPod" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]* types.Node {}, types .ErrNoETCD ).Once ()
136
- err := c .withNodesPodLocked (ctx , types.NodeFilter {Podname : "test" , All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
135
+ store .On ("GetNodesByPod" , mock .Anything , mock .Anything ).Return ([]* types.Node {}, types .ErrNoETCD ).Once ()
136
+ err := c .withNodesPodLocked (ctx , & types.NodeFilter {Podname : "test" , All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
137
137
assert .Error (t , err )
138
- store .On ("GetNodesByPod" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]* types.Node {}, nil ).Once ()
138
+ store .On ("GetNodesByPod" , mock .Anything , mock .Anything ).Return ([]* types.Node {}, nil ).Once ()
139
139
// failed by filter
140
140
var ns map [string ]* types.Node
141
- err = c .withNodesPodLocked (ctx , types.NodeFilter {Podname : "test" , Labels : map [string ]string {"eru" : "2" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
141
+ err = c .withNodesPodLocked (ctx , & types.NodeFilter {Podname : "test" , Labels : map [string ]string {"eru" : "2" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
142
142
ns = nodes
143
143
return nil
144
144
})
145
145
assert .NoError (t , err )
146
146
assert .Empty (t , ns )
147
- store .On ("GetNodesByPod" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]* types.Node {}, nil )
147
+ store .On ("GetNodesByPod" , mock .Anything , mock .Anything ).Return ([]* types.Node {}, nil )
148
148
// failed by getnode
149
149
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (nil , types .ErrNoETCD ).Once ()
150
- err = c .withNodesPodLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
150
+ err = c .withNodesPodLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
151
151
assert .Error (t , err )
152
152
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (node1 , nil ).Once ()
153
153
// failed by lock
@@ -156,16 +156,16 @@ func TestWithNodesPodLocked(t *testing.T) {
156
156
lock .On ("Unlock" , mock .Anything ).Return (nil )
157
157
// failed to get lock
158
158
lock .On ("Lock" , mock .Anything ).Return (context .TODO (), types .ErrNoETCD ).Once ()
159
- err = c .withNodesPodLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
159
+ err = c .withNodesPodLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
160
160
assert .Error (t , err )
161
161
lock .On ("Lock" , mock .Anything ).Return (ctx , nil )
162
162
// failed by get locked node
163
163
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (nil , types .ErrNoETCD ).Once ()
164
- err = c .withNodesPodLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
164
+ err = c .withNodesPodLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
165
165
assert .Error (t , err )
166
166
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (node1 , nil )
167
167
// success
168
- err = c .withNodesPodLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
168
+ err = c .withNodesPodLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
169
169
assert .Len (t , nodes , 1 )
170
170
return nil
171
171
})
@@ -224,22 +224,22 @@ func TestWithNodesOperationLocked(t *testing.T) {
224
224
Available : true ,
225
225
}
226
226
// failed by list nodes
227
- store .On ("GetNodesByPod" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]* types.Node {}, types .ErrNoETCD ).Once ()
228
- err := c .withNodesOperationLocked (ctx , types.NodeFilter {Podname : "test" , All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
227
+ store .On ("GetNodesByPod" , mock .Anything , mock .Anything ).Return ([]* types.Node {}, types .ErrNoETCD ).Once ()
228
+ err := c .withNodesOperationLocked (ctx , & types.NodeFilter {Podname : "test" , All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
229
229
assert .Error (t , err )
230
- store .On ("GetNodesByPod" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]* types.Node {}, nil ).Once ()
230
+ store .On ("GetNodesByPod" , mock .Anything , mock .Anything ).Return ([]* types.Node {}, nil ).Once ()
231
231
// failed by filter
232
232
var ns map [string ]* types.Node
233
- err = c .withNodesOperationLocked (ctx , types.NodeFilter {Podname : "test" , Labels : map [string ]string {"eru" : "2" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
233
+ err = c .withNodesOperationLocked (ctx , & types.NodeFilter {Podname : "test" , Labels : map [string ]string {"eru" : "2" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
234
234
ns = nodes
235
235
return nil
236
236
})
237
237
assert .NoError (t , err )
238
238
assert .Empty (t , ns )
239
- store .On ("GetNodesByPod" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]* types.Node {}, nil )
239
+ store .On ("GetNodesByPod" , mock .Anything , mock .Anything ).Return ([]* types.Node {}, nil )
240
240
// failed by getnode
241
241
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (nil , types .ErrNoETCD ).Once ()
242
- err = c .withNodesOperationLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
242
+ err = c .withNodesOperationLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
243
243
assert .Error (t , err )
244
244
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (node1 , nil ).Once ()
245
245
// failed by lock
@@ -248,16 +248,16 @@ func TestWithNodesOperationLocked(t *testing.T) {
248
248
lock .On ("Unlock" , mock .Anything ).Return (nil )
249
249
// failed to get lock
250
250
lock .On ("Lock" , mock .Anything ).Return (context .TODO (), types .ErrNoETCD ).Once ()
251
- err = c .withNodesOperationLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
251
+ err = c .withNodesOperationLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
252
252
assert .Error (t , err )
253
253
lock .On ("Lock" , mock .Anything ).Return (ctx , nil )
254
254
// failed by get locked node
255
255
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (nil , types .ErrNoETCD ).Once ()
256
- err = c .withNodesOperationLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
256
+ err = c .withNodesOperationLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error { return nil })
257
257
assert .Error (t , err )
258
258
store .On ("GetNode" , mock .Anything , mock .Anything ).Return (node1 , nil )
259
259
// success
260
- err = c .withNodesOperationLocked (ctx , types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
260
+ err = c .withNodesOperationLocked (ctx , & types.NodeFilter {Podname : "test" , Includes : []string {"test" }, All : false }, func (ctx context.Context , nodes map [string ]* types.Node ) error {
261
261
assert .Len (t , nodes , 1 )
262
262
return nil
263
263
})
0 commit comments