-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39cc03b
commit 009009e
Showing
2 changed files
with
11 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ func Test_GenerateRandomEmail(t *testing.T) { | |
|
||
func Test_EmailTransformerWithValue(t *testing.T) { | ||
testVal := "[email protected]" | ||
mapping := fmt.Sprintf(`root = emailtransformer("%s",true,true)`, testVal) | ||
mapping := fmt.Sprintf(`root = emailtransformer(%q,true,true)`, testVal) | ||
ex, err := bloblang.Parse(mapping) | ||
assert.NoError(t, err) | ||
assert.NoError(t, err, "failed to parse the email transformer") | ||
|
@@ -104,7 +104,7 @@ func Test_EmailTransformerWithValue(t *testing.T) { | |
|
||
func Test_EmailTransformerWithEmptyValue(t *testing.T) { | ||
testVal := "" | ||
mapping := fmt.Sprintf(`root = emailtransformer("%s",true,true)`, testVal) | ||
mapping := fmt.Sprintf(`root = emailtransformer(%q,true,true)`, testVal) | ||
ex, err := bloblang.Parse(mapping) | ||
assert.NoError(t, err) | ||
assert.NoError(t, err, "failed to parse the email transformer") | ||
|
@@ -123,7 +123,7 @@ func Test_EmailTransformerEmailParamError(t *testing.T) { | |
} | ||
func Test_EmailTransformerPreserveLengthParamError(t *testing.T) { | ||
testVal := "" | ||
mapping := fmt.Sprintf(`root = emailtransformer("%s",true)`, testVal) | ||
mapping := fmt.Sprintf(`root = emailtransformer(%q,true)`, testVal) | ||
_, err := bloblang.Parse(mapping) | ||
assert.Error(t, err, "failed to parse the email transformer, missing param") | ||
|
||
|
@@ -135,6 +135,14 @@ func Test_EmailTransformerErrorParams(t *testing.T) { | |
|
||
} | ||
|
||
func Test_ParseEmailError(t *testing.T) { | ||
test := "ehiu.com" | ||
|
||
_, err := parseEmail(test) | ||
assert.Error(t, err) | ||
|
||
} | ||
|
||
func isValidEmail(email string) bool { | ||
// Regular expression pattern for a simple email validation | ||
emailPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$` | ||
|