Skip to content

Commit

Permalink
For email validation given a real domain and a real address also made…
Browse files Browse the repository at this point in the history
… more tests
  • Loading branch information
Siposattila committed May 20, 2024
1 parent a8cab93 commit 530965b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/email/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func (e *Email) verifyEmail() bool {
}
defer client.Close()

client.Hello("localhost") // TODO: needs real domain
client.Mail("me@example.com") // TODO: needs real email
client.Hello("gobulk.com")
client.Mail("info@gobulk.com")
rcptErr := client.Rcpt(e.Email)
client.Quit()

Expand Down
18 changes: 18 additions & 0 deletions test/email_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@ func TestValidatorOnBadEmail(t *testing.T) {
t.Fatalf("e.Valid should not be true on iepwhfepwifhewipfeh@gmail.com")
}
}

func TestValidatorOnGmail(t *testing.T) {
e := email.Email{Email: "gobulk189@gmail.com"}
e.ValidateEmail()

if e.Valid == email.EMAIL_INVALID {
t.Fatalf("e.Valid should be true on gobulk189@gmail.com")
}
}

func TestValidatorOnFreemail(t *testing.T) {
e := email.Email{Email: "gobulk@fremail.hu"}
e.ValidateEmail()

if e.Valid == email.EMAIL_INVALID {
t.Fatalf("e.Valid should be true on gobulk@fremail.hu")
}
}

0 comments on commit 530965b

Please sign in to comment.