Skip to content

Commit

Permalink
test: better formatting when dumping objects
Browse files Browse the repository at this point in the history
we expect the JSON format to be more readable than go fmt struct dump

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed May 9, 2023
1 parent 370f45d commit 1652401
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/integration/noderesourcetopology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package integration

import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"
Expand Down Expand Up @@ -211,7 +212,7 @@ func TestTopologyMatchPlugin(t *testing.T) {
t.Fatalf("Failed to create Node %q: %v", nodeName, err)
}

t.Logf(" Node %s created: %v", nodeName, n)
t.Logf(" Node %s created: %s", nodeName, formatObject(n))
}

nodeList, err := cs.CoreV1().Nodes().List(testCtx.Ctx, metav1.ListOptions{})
Expand Down Expand Up @@ -2163,3 +2164,11 @@ func podFailedScheduling(c clientset.Interface, podNamespace, podName string) ([
}
return failedSchedulingEvents, nil
}

func formatObject(obj interface{}) string {
bytes, err := json.Marshal(obj)
if err != nil {
return fmt.Sprintf("<ERROR: %s>", err)
}
return string(bytes)
}

0 comments on commit 1652401

Please sign in to comment.