From a0a47c6570e18e8f151989fc8f2af3c9436c42b7 Mon Sep 17 00:00:00 2001 From: Klaus Ma Date: Thu, 2 Feb 2017 11:44:25 +0800 Subject: [PATCH] Improve the code coverage of /plugin/pkg/admission/deny --- plugin/pkg/admission/deny/admission_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/pkg/admission/deny/admission_test.go b/plugin/pkg/admission/deny/admission_test.go index 7cf1daeeb4e..a2a6f32d9b3 100644 --- a/plugin/pkg/admission/deny/admission_test.go +++ b/plugin/pkg/admission/deny/admission_test.go @@ -27,6 +27,17 @@ func TestAdmission(t *testing.T) { handler := NewAlwaysDeny() err := handler.Admit(admission.NewAttributesRecord(nil, nil, api.Kind("kind").WithVersion("version"), "namespace", "name", api.Resource("resource").WithVersion("version"), "subresource", admission.Create, nil)) if err == nil { - t.Errorf("Expected error returned from admission handler") + t.Error("Expected error returned from admission handler") + } +} + +func TestHandles(t *testing.T) { + handler := NewAlwaysDeny() + tests := []admission.Operation{admission.Create, admission.Connect, admission.Update, admission.Delete} + + for _, test := range tests { + if !handler.Handles(test) { + t.Errorf("Expected handling all operations, including: %v", test) + } } }