@@ -267,27 +267,30 @@ func TestIsUpdateCheckEnabled(t *testing.T) {
267
267
268
268
func TestIsDefaultLocal (t * testing.T ) {
269
269
tests := []struct {
270
- context string
270
+ cfg * ContextConfig
271
271
expectedLocal bool
272
272
}{
273
- {context : "kind-other" , expectedLocal : true },
274
- {context : "kind@kind" , expectedLocal : true },
275
- {context : "k3d-k3s-default" , expectedLocal : true },
276
- {context : "docker-for-desktop" , expectedLocal : true },
277
- {context : "minikube" , expectedLocal : true },
278
- {context : "docker-desktop" , expectedLocal : true },
279
- {context : "anything-else" , expectedLocal : false },
280
- {context : "kind@blah" , expectedLocal : false },
281
- {context : "other-kind" , expectedLocal : false },
282
- {context : "not-k3d" , expectedLocal : false },
273
+ {cfg : & ContextConfig {Kubecontext : "kind-other" }, expectedLocal : true },
274
+ {cfg : & ContextConfig {Kubecontext : "kind-other" , KindDisableLoad : util .BoolPtr (true )}, expectedLocal : false },
275
+ {cfg : & ContextConfig {Kubecontext : "kind@kind" }, expectedLocal : true },
276
+ {cfg : & ContextConfig {Kubecontext : "k3d-k3s-default" }, expectedLocal : true },
277
+ {cfg : & ContextConfig {Kubecontext : "k3d-k3s-default" , K3dDisableLoad : util .BoolPtr (true )}, expectedLocal : false },
278
+ {cfg : & ContextConfig {Kubecontext : "docker-for-desktop" }, expectedLocal : true },
279
+ {cfg : & ContextConfig {Kubecontext : "minikube" }, expectedLocal : true },
280
+ {cfg : & ContextConfig {Kubecontext : "docker-desktop" }, expectedLocal : true },
281
+ {cfg : & ContextConfig {Kubecontext : "anything-else" }, expectedLocal : false },
282
+ {cfg : & ContextConfig {Kubecontext : "kind@blah" }, expectedLocal : false },
283
+ {cfg : & ContextConfig {Kubecontext : "other-kind" }, expectedLocal : false },
284
+ {cfg : & ContextConfig {Kubecontext : "not-k3d" }, expectedLocal : false },
283
285
}
284
286
for _ , test := range tests {
285
287
testutil .Run (t , "" , func (t * testutil.T ) {
288
+ t .Override (& GetConfigForCurrentKubectx , func (string ) (* ContextConfig , error ) { return test .cfg , nil })
286
289
t .Override (& cluster .GetClient , func () cluster.Client { return fakeClient {} })
287
290
288
- local := isDefaultLocal (test . context , true )
291
+ local , _ := isDefaultLocal ("dummyname" , true )
289
292
t .CheckDeepEqual (test .expectedLocal , local )
290
- local = isDefaultLocal (test . context , false )
293
+ local , _ = isDefaultLocal ("dummyname" , false )
291
294
t .CheckDeepEqual (test .expectedLocal , local )
292
295
})
293
296
}
0 commit comments