forked from truemail-rb/truemail-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regex_test.go
27 lines (21 loc) · 862 Bytes
/
regex_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package truemail
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidationRegexCheck(t *testing.T) {
t.Run("regex validation: successful", func(t *testing.T) {
validatorResult := createSuccessfulValidatorResult(randomEmail(), createConfiguration())
new(validationRegex).check(validatorResult)
assert.True(t, validatorResult.Success)
assert.Empty(t, validatorResult.Errors)
assert.Empty(t, validatorResult.usedValidations)
})
t.Run("regex validation: failure", func(t *testing.T) {
validatorResult := createSuccessfulValidatorResult("invalid@email", createConfiguration())
new(validationRegex).check(validatorResult)
assert.False(t, validatorResult.Success)
assert.Equal(t, map[string]string{validationTypeRegex: regexErrorContext}, validatorResult.Errors)
assert.Empty(t, validatorResult.usedValidations)
})
}