Add tests for mode check.

This commit is contained in:
Anna Rose Wiggins 2025-07-16 21:00:23 -04:00
parent fbb26fd93a
commit a34a90238c

View file

@ -0,0 +1,53 @@
package mappingrules
import (
"testing"
"github.com/stretchr/testify/suite"
)
type MappingRuleBaseTests struct {
suite.Suite
}
func TestRunnerMappingRuleBaseTests(t *testing.T) {
suite.Run(t, new(MappingRuleBaseTests))
}
func (t *MappingRuleBaseTests) TestNewMappingRuleBase() {
t.Run("No Modes", func() {
base := NewMappingRuleBase("foo", []string{})
t.Equal("foo", base.Name)
t.EqualValues([]string{"*"}, base.Modes)
})
t.Run("Has Modes", func() {
base := NewMappingRuleBase("foo", []string{"bar", "baz"})
t.Equal("foo", base.Name)
t.Contains(base.Modes, "bar")
t.Contains(base.Modes, "baz")
t.NotContains(base.Modes, "*")
})
}
func (t *MappingRuleBaseTests) TestModeCheck() {
t.Run("* works on all modes", func() {
base := NewMappingRuleBase("", []string{})
mode := "bar"
t.True(base.modeCheck(&mode))
mode = "baz"
t.True(base.modeCheck(&mode))
})
t.Run("single mode only works in that mode", func() {
base := NewMappingRuleBase("", []string{"bar"})
mode := "bar"
t.True(base.modeCheck(&mode))
mode = "baz"
t.False(base.modeCheck(&mode))
})
t.Run("multiple modes work in each mode", func() {
})
}