mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Improve style of kubelet node status test
This commit is contained in:
parent
67387632dc
commit
c0e3efb4db
@ -1016,6 +1016,10 @@ func TestTryRegisterWithApiServer(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notImplemented := func(action core.Action) (bool, runtime.Object, error) {
|
||||||
|
return true, nil, fmt.Errorf("no reaction implemented for %s", action)
|
||||||
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled is a don't-care for this test */)
|
testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled is a don't-care for this test */)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
@ -1028,17 +1032,17 @@ func TestTryRegisterWithApiServer(t *testing.T) {
|
|||||||
// Return an existing (matching) node on get.
|
// Return an existing (matching) node on get.
|
||||||
return true, tc.existingNode, tc.getError
|
return true, tc.existingNode, tc.getError
|
||||||
})
|
})
|
||||||
kubeClient.AddReactor("update", "*", func(action core.Action) (bool, runtime.Object, error) {
|
kubeClient.AddReactor("update", "nodes", func(action core.Action) (bool, runtime.Object, error) {
|
||||||
if action.GetResource().Resource == "nodes" && action.GetSubresource() == "status" {
|
if action.GetSubresource() == "status" {
|
||||||
return true, nil, tc.updateError
|
return true, nil, tc.updateError
|
||||||
}
|
}
|
||||||
return true, nil, fmt.Errorf("no reaction implemented for %s", action)
|
return notImplemented(action)
|
||||||
})
|
})
|
||||||
kubeClient.AddReactor("delete", "nodes", func(action core.Action) (bool, runtime.Object, error) {
|
kubeClient.AddReactor("delete", "nodes", func(action core.Action) (bool, runtime.Object, error) {
|
||||||
return true, nil, tc.deleteError
|
return true, nil, tc.deleteError
|
||||||
})
|
})
|
||||||
kubeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {
|
kubeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {
|
||||||
return true, nil, fmt.Errorf("no reaction implemented for %s", action)
|
return notImplemented(action)
|
||||||
})
|
})
|
||||||
|
|
||||||
result := kubelet.tryRegisterWithApiServer(tc.newNode)
|
result := kubelet.tryRegisterWithApiServer(tc.newNode)
|
||||||
|
Loading…
Reference in New Issue
Block a user