From 32d8fa005840ed4f7840b654677b74f6d066abe7 Mon Sep 17 00:00:00 2001 From: "Sahdev P. Zala" Date: Tue, 7 Nov 2017 20:33:03 -0500 Subject: [PATCH] Fix an unreachable kubectl explain field lookup test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In error case, the condition “gotErr != test.err && gotPath != test.expectedPath” never fulfill because in this case both gotPath and test.expectedPath always an empty string. So the err “err: `field "what?" does not exist`” doesn’t get tasted. For example, if you change the value of “err” to anything, the test still will pass. Also, since gotPath is empty string in case of err, in the output error we probably don’t want to display path. --- pkg/kubectl/explain/field_lookup_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/kubectl/explain/field_lookup_test.go b/pkg/kubectl/explain/field_lookup_test.go index 4120c31f336..239ad704005 100644 --- a/pkg/kubectl/explain/field_lookup_test.go +++ b/pkg/kubectl/explain/field_lookup_test.go @@ -69,9 +69,9 @@ func TestFindField(t *testing.T) { gotPath = path.GetPath().String() } - if gotErr != test.err && gotPath != test.expectedPath { - t.Errorf("LookupSchemaForField(schema, %v) = (%v, %v), expected (%s, %v)", - test.path, gotErr, gotPath, test.expectedPath, test.err) + if gotErr != test.err || gotPath != test.expectedPath { + t.Errorf("LookupSchemaForField(schema, %v) = (path: %q, err: %q), expected (path: %q, err: %q)", + test.path, gotPath, gotErr, test.expectedPath, test.err) } } }