-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtopology_test.go
More file actions
49 lines (42 loc) · 903 Bytes
/
Copy pathtopology_test.go
File metadata and controls
49 lines (42 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package ssp
import (
"strconv"
"testing"
"github.com/affo/ssp/values"
"github.com/google/go-cmp/cmp"
)
var _ Node = (*BaseNode)(nil)
type BaseNode struct {
*AnonymousNode
}
func Test_NewTopology(t *testing.T) {
ctx := Context()
ns := make([]Node, 8)
for i := 0; i < len(ns); i++ {
ns[i] = NewNode(func(collector Collector, v values.Value) error {
return nil
}).SetName(strconv.FormatInt(int64(i), 10))
}
o := ns[0].Out().Connect(ctx, ns[1]).Out()
// Multiple out.
o.Connect(ctx, ns[2])
o.Connect(ctx, ns[3])
// Multiple in.
ns[2].Out().Connect(ctx, ns[4])
ns[3].Out().Connect(ctx, ns[4])
ns[4].Out().Connect(ctx, ns[5])
// Disconnected piece.
ns[6].Out().Connect(ctx, ns[7])
g := GetGraph(ctx)
want := `0 -> 1
1 -> 2
1 -> 3
2 -> 4
3 -> 4
4 -> 5
6 -> 7
`
if diff := cmp.Diff(want, g.String()); diff != "" {
t.Errorf("unexpected result -want/+got:\n\t%s", diff)
}
}