twitch-bot/plugins/actorkit_test.go
2023-08-18 18:10:02 +02:00

27 lines
658 B
Go

package plugins
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidateRequireNonEmpty(t *testing.T) {
attrs := FieldCollectionFromData(map[string]any{
"str": "",
"str_v": "valid",
"int": 0,
"int_v": 1,
})
for _, field := range []string{"int", "str"} {
errUnset := ActorKit{}.ValidateRequireNonEmpty(attrs, strings.Join([]string{field, "unset"}, "_"))
errInval := ActorKit{}.ValidateRequireNonEmpty(attrs, field)
errValid := ActorKit{}.ValidateRequireNonEmpty(attrs, strings.Join([]string{field, "v"}, "_"))
assert.Error(t, errUnset)
assert.Error(t, errInval)
assert.NoError(t, errValid)
}
}