-
Notifications
You must be signed in to change notification settings - Fork 125
/
graph_ports_test.go
65 lines (51 loc) · 1.09 KB
/
graph_ports_test.go
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package goflow
import "testing"
func TestOutportNotFound(t *testing.T) {
sub, err := newDoubleEcho()
if err != nil {
t.Error(err)
return
}
n := NewGraph()
if err := n.Add("sub", sub); err != nil {
t.Error(err)
return
}
n.Add("e3", new(echo))
if err := n.Connect("sub", "NoOut", "e3", "In"); err == nil {
t.Errorf("Expected an error")
}
}
func TestInPortNotFound(t *testing.T) {
sub, err := newDoubleEcho()
if err != nil {
t.Error(err)
return
}
n := NewGraph()
if err := n.Add("sub", sub); err != nil {
t.Error(err)
return
}
n.Add("e3", new(echo))
if err := n.Connect("e3", "Out", "sub", "NotIn"); err == nil {
t.Errorf("Expected an error")
}
}
func TestSetMissingProcPorts(t *testing.T) {
n := NewGraph()
if err := n.Add("e1", new(echo)); err != nil {
t.Error(err)
return
}
n.MapInPort("In", "nope", "In")
n.MapOutPort("Out", "nope", "Out")
if err := n.SetInPort("In", make(chan int)); err == nil {
t.Errorf("Expected an error")
return
}
if err := n.SetOutPort("Out", make(chan int)); err == nil {
t.Errorf("Expected an error")
return
}
}