config_helpers_test.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package config
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "testing"
  5. )
  6. func TestFindAction(t *testing.T) {
  7. c := DefaultConfig()
  8. a1 := Action{}
  9. a1.Title = "a1"
  10. c.Actions = append(c.Actions, a1)
  11. a2 := Action{
  12. Title: "a2",
  13. Arguments: []ActionArgument{
  14. {
  15. Name: "Blat",
  16. },
  17. },
  18. }
  19. c.Actions = append(c.Actions, a2)
  20. assert.NotNil(t, c.FindAction("a1"), "Find action a1")
  21. assert.NotNil(t, c.FindAction("a2"), "Find action a2")
  22. assert.NotNil(t, c.FindAction("a2").FindArg("Blat"), "Find action argument")
  23. assert.Nil(t, c.FindAction("a2").FindArg("Blatey Cake"), "Find non-existent action argument")
  24. assert.Nil(t, c.FindAction("waffles"), "Find non-existent action")
  25. }
  26. func TestFindAcl(t *testing.T) {
  27. c := DefaultConfig()
  28. acl1 := AccessControlList{
  29. Name: "Testing ACL",
  30. }
  31. c.AccessControlLists = append(c.AccessControlLists, acl1)
  32. assert.NotNil(t, c.FindAcl("Testing ACL"), "Find a ACL that should exist")
  33. assert.Nil(t, c.FindAcl("Chocolate Cake"), "Find a ACL that does not exist")
  34. }