Files
console/validator/enum_test.go
2020-10-25 10:00:59 +03:00

25 lines
532 B
Go

package validator_test
import (
"errors"
"testing"
"gitoa.ru/go-4devs/console/input/value"
"gitoa.ru/go-4devs/console/validator"
)
func TestEnum(t *testing.T) {
validValue := value.New("valid")
invalidValue := value.New("invalid")
enum := validator.Enum("valid", "other", "three")
if err := enum(validValue); err != nil {
t.Errorf("expected valid value got err:%s", err)
}
if err := enum(invalidValue); !errors.Is(err, validator.ErrInvalid) {
t.Errorf("expected err:%s, got: %s", validator.ErrInvalid, err)
}
}