-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircular_test.go
More file actions
44 lines (42 loc) · 1.26 KB
/
Copy pathcircular_test.go
File metadata and controls
44 lines (42 loc) · 1.26 KB
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
package nodegraphflow
import (
"fmt"
"testing"
)
func TestBuildChain(t *testing.T) {
n1 := Node[TestPayload]{Name: "node1", Task: func(ctx *FlowContext, i TestPayload) (TestPayload, error) {
fmt.Println("Node1")
return TestPayload{}, nil
}}
n2 := Node[TestPayload]{Name: "node2", ParentNode: &n1, Task: func(ctx *FlowContext, i TestPayload) (TestPayload, error) {
fmt.Println("Node2")
return TestPayload{}, nil
}}
n3 := Node[TestPayload]{Name: "node3", Task: func(ctx *FlowContext, i TestPayload) (TestPayload, error) {
fmt.Println("Node3")
return TestPayload{}, nil
}}
n4 := Node[TestPayload]{Name: "node4", Task: func(ctx *FlowContext, i TestPayload) (TestPayload, error) {
fmt.Println("Node4")
return TestPayload{}, AbortError{}
}}
n5 := Node[TestPayload]{Name: "node5", Task: func(ctx *FlowContext, i TestPayload) (TestPayload, error) {
fmt.Println("Node5")
return TestPayload{State: "Success"}, nil
}}
type args struct {
nodes []*Node[TestPayload]
}
tests := []struct {
name string
args args
}{
{name: "Test BuildChain", args: args{nodes: []*Node[TestPayload]{&n1, &n2, &n3, &n4, &n5}}},
}
for _, tt := range tests {
stopChain := make(chan int, 1)
t.Run(tt.name, func(t *testing.T) {
BuildChain(&stopChain, tt.args.nodes...)
})
}
}