Browse Source

Apparently I was a bit overzealous in removing nil checks

Willem Monsuwe 4 years ago
parent
commit
aed3d30736
1 changed files with 8 additions and 6 deletions
  1. 8 6
      pkg/provider/webhook/webhook_test.go

+ 8 - 6
pkg/provider/webhook/webhook_test.go

@@ -281,12 +281,14 @@ func testGetSecretMap(tc testCase, t *testing.T, client provider.SecretsClient)
 	if (tc.Want.Err == "") != (errStr == "") || !strings.Contains(errStr, tc.Want.Err) {
 		t.Errorf("%s: unexpected error: '%s' (expected '%s')", tc.Case, errStr, tc.Want.Err)
 	}
-	for wantkey, wantval := range tc.Want.ResultMap {
-		gotval, ok := secretmap[wantkey]
-		if !ok {
-			t.Errorf("%s: unexpected response: wanted key '%s' not found", tc.Case, wantkey)
-		} else if string(gotval) != wantval {
-			t.Errorf("%s: unexpected response: key '%s' = '%s' (expected '%s')", tc.Case, wantkey, wantval, gotval)
+	if err == nil {
+		for wantkey, wantval := range tc.Want.ResultMap {
+			gotval, ok := secretmap[wantkey]
+			if !ok {
+				t.Errorf("%s: unexpected response: wanted key '%s' not found", tc.Case, wantkey)
+			} else if string(gotval) != wantval {
+				t.Errorf("%s: unexpected response: key '%s' = '%s' (expected '%s')", tc.Case, wantkey, wantval, gotval)
+			}
 		}
 	}
 }