-
Notifications
You must be signed in to change notification settings - Fork 48
/
actions_test.go
59 lines (51 loc) · 1.07 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
package tc
import "testing"
func TestActions(t *testing.T) {
tcSocket, done := testConn(t)
defer done()
t.Run("ErrNoArg", func(t *testing.T) {
err := tcSocket.Actions().Add(nil)
if err != ErrNoArg {
t.Fatalf("expected ErrNoArg, received: %v", err)
}
err = tcSocket.Actions().Replace(nil)
if err != ErrNoArg {
t.Fatalf("expected ErrNoArg, received: %v", err)
}
err = tcSocket.Actions().Delete(nil)
if err != ErrNoArg {
t.Fatalf("expected ErrNoArg, received: %v", err)
}
})
t.Run("simple example", func(t *testing.T) {
newActions := []*Action{
{
Kind: "mirred",
Mirred: &Mirred{
Parms: &MirredParam{
Index: 42,
Action: 1337,
},
},
},
{
Kind: "gact",
Gact: &Gact{
Parms: &GactParms{
Index: 1337,
Action: 42,
},
},
},
}
if err := tcSocket.Actions().Add(newActions); err != nil {
t.Fatal(err)
}
if err := tcSocket.Actions().Replace(newActions); err != nil {
t.Fatal(err)
}
if err := tcSocket.Actions().Delete(newActions); err != nil {
t.Fatal(err)
}
})
}