From c0e3efb4dbe573b296559c954c4c5c563bc367aa Mon Sep 17 00:00:00 2001 From: Paul Morie Date: Mon, 5 Sep 2016 00:23:43 -0400 Subject: [PATCH] Improve style of kubelet node status test --- pkg/kubelet/kubelet_node_status_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/kubelet/kubelet_node_status_test.go b/pkg/kubelet/kubelet_node_status_test.go index 3287cb6857a..fae21e4a026 100644 --- a/pkg/kubelet/kubelet_node_status_test.go +++ b/pkg/kubelet/kubelet_node_status_test.go @@ -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 { testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled is a don't-care for this test */) kubelet := testKubelet.kubelet @@ -1028,17 +1032,17 @@ func TestTryRegisterWithApiServer(t *testing.T) { // Return an existing (matching) node on get. return true, tc.existingNode, tc.getError }) - kubeClient.AddReactor("update", "*", func(action core.Action) (bool, runtime.Object, error) { - if action.GetResource().Resource == "nodes" && action.GetSubresource() == "status" { + kubeClient.AddReactor("update", "nodes", func(action core.Action) (bool, runtime.Object, error) { + if action.GetSubresource() == "status" { 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) { return true, nil, tc.deleteError }) 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)