MCPcopy
hub / github.com/apecloud/kubeblocks / TestXConnect

Function TestXConnect

pkg/controller/graph/dag_test.go:108–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestXConnect(t *testing.T) {
109 dag := NewDAG()
110 v1, v2 := 3, 5
111 connected := dag.Connect(nil, v2)
112 if connected {
113 t.Error("connect nil vertex should return false")
114 }
115 connected = dag.Connect(v1, v2)
116 if !connected {
117 t.Errorf("connect %v to %v failed", v1, v2)
118 }
119 connected = dag.Connect(v1, v2)
120 if !connected {
121 t.Errorf("connect %v to %v failed", v1, v2)
122 }
123 if len(dag.edges) != 1 {
124 t.Error("connect failed")
125 }
126 for edge := range dag.edges {
127 if edge.From() != v1 || edge.To() != v2 {
128 t.Errorf("edge in dag: %v, edge need: %v", edge, RealEdge(v1, v2))
129 }
130 }
131
132 v3 := 7
133 connected = dag.AddConnect(v1, nil)
134 if connected {
135 t.Error("AddConnect nil vertex should return false")
136 }
137 connected = dag.AddConnect(v1, v3)
138 if !connected {
139 t.Errorf("AddConnect %v to %v should succeed", v1, v3)
140 }
141 v4 := 9
142 connected = dag.AddConnectRoot(v4)
143 if connected {
144 t.Errorf("AddConnectRoot to %v with nil root should failed", v4)
145 }
146 dag.AddVertex(v1)
147 connected = dag.AddConnectRoot(v4)
148 if !connected {
149 t.Errorf("AddConnectRoot to %v should succeed", v4)
150 }
151}
152
153func TestWalkTopoOrder(t *testing.T) {
154 dag := newTestDAG()

Callers

nothing calls this directly

Calls 9

ConnectMethod · 0.95
AddConnectMethod · 0.95
AddConnectRootMethod · 0.95
AddVertexMethod · 0.95
NewDAGFunction · 0.85
RealEdgeFunction · 0.85
FromMethod · 0.65
ToMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…