You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
538 B
25 lines
538 B
4 years ago
|
package validator_test
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"testing"
|
||
|
|
||
4 years ago
|
"gitoa.ru/go-4devs/console/input/validator"
|
||
4 years ago
|
"gitoa.ru/go-4devs/console/input/value"
|
||
|
)
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
}
|