MCPcopy
hub / github.com/containerd/containerd / checkNodesEqual

Function checkNodesEqual

core/metadata/gc_test.go:753–785  ·  view source on GitHub ↗
(t *testing.T, n1, n2 []gc.Node)

Source from the content-addressed store, hash-verified

751}
752
753func checkNodesEqual(t *testing.T, n1, n2 []gc.Node) {
754 t.Helper()
755 sort.Sort(nodeList(n1))
756 sort.Sort(nodeList(n2))
757
758 if len(n1) != len(n2) {
759 buf := bytes.NewBuffer(nil)
760 tw := tabwriter.NewWriter(buf, 8, 4, 1, ' ', 0)
761 max := len(n1)
762 if len(n2) > max {
763 max = len(n2)
764 }
765 fmt.Fprintln(tw, "Expected:\tActual:")
766 for i := 0; i < max; i++ {
767 var left, right string
768 if i < len(n1) {
769 right = printNode(n1[i])
770 }
771 if i < len(n2) {
772 left = printNode(n2[i])
773 }
774 fmt.Fprintln(tw, left+"\t"+right)
775 }
776 tw.Flush()
777 t.Fatal("Nodes do not match\n" + buf.String())
778 }
779
780 for i := range n1 {
781 if n1[i] != n2[i] {
782 t.Errorf("[%d] root does not match expected: expected %v, got %v", i, printNode(n2[i]), printNode(n1[i]))
783 }
784 }
785}
786
787func printNode(n gc.Node) string {
788 var t string

Callers 3

checkNodeCFunction · 0.85
checkNodesFunction · 0.85
TestMetadataCollectorFunction · 0.85

Calls 5

FlushMethod · 0.95
nodeListTypeAlias · 0.85
FatalMethod · 0.80
printNodeFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…