-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathactions_test.go
62 lines (50 loc) · 1.31 KB
/
actions_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
package ofputil
import (
"reflect"
"testing"
"github.com/netrack/openflow/ofp"
)
func TestActionsApply(t *testing.T) {
ac1 := ofp.ActionCopyTTLIn{}
ac2 := ofp.ActionDecNetworkTTL{}
ac3 := ofp.ActionOutput{Port: 2}
its := ActionsApply(&ac1, &ac2, &ac3)
if len(its) != 1 {
t.Fatalf("Expected one instruction in apply actions")
}
// Cast the instruction interface to apply action.
itaa, ok := its[0].(*ofp.InstructionApplyActions)
if !ok {
t.Fatalf("Should be an apply action instruction")
}
aa := ofp.Actions{&ac1, &ac2, &ac3}
if !reflect.DeepEqual(itaa.Actions, aa) {
t.Fatalf("Actions are not the same")
}
}
func TestActionsWrite(t *testing.T) {
ac1 := ofp.ActionSetNetworkTTL{128}
ac2 := ofp.ActionGroup{3}
its := ActionsWrite(&ac1, &ac2)
if len(its) != 1 {
t.Fatalf("Expected one instruction in write actions")
}
itwa, ok := its[0].(*ofp.InstructionWriteActions)
if !ok {
t.Fatalf("Should be a write action instruction")
}
wa := ofp.Actions{&ac1, &ac2}
if !reflect.DeepEqual(itwa.Actions, wa) {
t.Fatalf("Actions are not the same")
}
}
func TestActionsClear(t *testing.T) {
its := ActionsClear()
if len(its) != 1 {
t.Fatalf("Expected one instruction in clear actions")
}
_, ok := its[0].(*ofp.InstructionClearActions)
if !ok {
t.Fatalf("Should be a clear action instruction")
}
}