Add more tests (#4)
This also refactors some of the code parsing logic. Reviewed-on: #4 Co-authored-by: Anna Rose Wiggins <annabunches@gmail.com> Co-committed-by: Anna Rose Wiggins <annabunches@gmail.com>
This commit is contained in:
parent
a05dc9126d
commit
712dcdbc07
7 changed files with 198 additions and 83 deletions
53
internal/mappingrules/mapping_rule_base_test.go
Normal file
53
internal/mappingrules/mapping_rule_base_test.go
Normal 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() {
|
||||
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue