mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-14 02:52:42 +00:00
27 lines
658 B
Go
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)
|
|
}
|
|
}
|