diff --git a/pkg/api/testing/compat/BUILD b/pkg/api/testing/compat/BUILD index b08e25c8df7..a5890df5358 100644 --- a/pkg/api/testing/compat/BUILD +++ b/pkg/api/testing/compat/BUILD @@ -11,7 +11,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/api/testing/compat", deps = [ "//pkg/api/legacyscheme:go_default_library", - "//pkg/printers:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", diff --git a/pkg/api/testing/compat/compatibility_tester.go b/pkg/api/testing/compat/compatibility_tester.go index 5fbdc01e301..68b4bc9a852 100644 --- a/pkg/api/testing/compat/compatibility_tester.go +++ b/pkg/api/testing/compat/compatibility_tester.go @@ -19,7 +19,6 @@ package compat import ( "encoding/json" "fmt" - "os" "reflect" "regexp" "strconv" @@ -30,7 +29,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kubernetes/pkg/api/legacyscheme" - "k8s.io/kubernetes/pkg/printers" ) // Based on: https://github.com/openshift/origin/blob/master/pkg/api/compatibility_test.go @@ -72,14 +70,11 @@ func TestCompatibility( t.Fatalf("Unexpected error: %v", err) } - hasError := false for k, expectedValue := range expectedKeys { keys := strings.Split(k, ".") if actualValue, ok, err := getJSONValue(generic, keys...); err != nil || !ok { t.Errorf("Unexpected error for %s: %v", k, err) - hasError = true } else if !reflect.DeepEqual(expectedValue, fmt.Sprintf("%v", actualValue)) { - hasError = true t.Errorf("Unexpected value for %v: expected %v, got %v", k, expectedValue, actualValue) } } @@ -89,14 +84,17 @@ func TestCompatibility( actualValue, ok, err := getJSONValue(generic, keys...) if err == nil || ok { t.Errorf("Unexpected value found for key %s: %v", absentKey, actualValue) - hasError = true } } - if hasError { - printer := &printers.JSONPrinter{} - printer.PrintObj(obj, os.Stdout) - t.Logf("2: Encoded value: %#v", string(output)) + if t.Failed() { + data, err := json.MarshalIndent(obj, "", " ") + if err != nil { + t.Log(err) + } else { + t.Log(string(data)) + } + t.Logf("2: Encoded value: %v", string(output)) } }