Skip to content

Commit 1652401

Browse files
committed
test: better formatting when dumping objects
we expect the JSON format to be more readable than go fmt struct dump Signed-off-by: Francesco Romani <[email protected]>
1 parent 370f45d commit 1652401

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/integration/noderesourcetopology_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package integration
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"fmt"
2223
"strings"
2324
"testing"
@@ -211,7 +212,7 @@ func TestTopologyMatchPlugin(t *testing.T) {
211212
t.Fatalf("Failed to create Node %q: %v", nodeName, err)
212213
}
213214

214-
t.Logf(" Node %s created: %v", nodeName, n)
215+
t.Logf(" Node %s created: %s", nodeName, formatObject(n))
215216
}
216217

217218
nodeList, err := cs.CoreV1().Nodes().List(testCtx.Ctx, metav1.ListOptions{})
@@ -2163,3 +2164,11 @@ func podFailedScheduling(c clientset.Interface, podNamespace, podName string) ([
21632164
}
21642165
return failedSchedulingEvents, nil
21652166
}
2167+
2168+
func formatObject(obj interface{}) string {
2169+
bytes, err := json.Marshal(obj)
2170+
if err != nil {
2171+
return fmt.Sprintf("<ERROR: %s>", err)
2172+
}
2173+
return string(bytes)
2174+
}

0 commit comments

Comments
 (0)