Skip to content

Commit

Permalink
Add test for actions
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Lehner <[email protected]>
  • Loading branch information
florianl committed Aug 3, 2024
1 parent 0e5a288 commit e0d2384
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions actions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
}
})
}

0 comments on commit e0d2384

Please sign in to comment.