sanitize_test.go 799 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package config
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "testing"
  5. )
  6. func TestSanitizeConfig(t *testing.T) {
  7. c := DefaultConfig()
  8. a := &Action{
  9. Title: "Mr Waffles",
  10. Arguments: []ActionArgument{
  11. {
  12. Name: "Carrots",
  13. Choices: []ActionArgumentChoice{
  14. {
  15. Value: "Waffle",
  16. },
  17. },
  18. },
  19. {
  20. Name: "foobar",
  21. },
  22. },
  23. }
  24. c.Actions = append(c.Actions, a)
  25. c.Sanitize()
  26. a2 := c.FindAction("Mr Waffles")
  27. assert.NotNil(t, a2, "Found action after adding it")
  28. assert.Equal(t, 3, a2.Timeout, "Default timeout is set")
  29. assert.Equal(t, "😀", a2.Icon, "Default icon is a smiley")
  30. assert.Equal(t, "Carrots", a2.Arguments[0].Title, "Arg title is set to name")
  31. assert.Equal(t, "Waffle", a2.Arguments[0].Choices[0].Title, "Choice title is set to name")
  32. }