package email_test

import (
	"testing"

	email "github.com/gopherguides/learn/_training/fundamentals/testing/src/coverage"
)

func Test_ValidateEmail(t *testing.T) {
	t.Parallel()
	tests := []struct {
		name      string
		em        string
		expectErr bool
	}{
		{name: "blank", em: "", expectErr: true},
		{name: "at", em: "yahoo.com", expectErr: true},
	}

	for _, test := range tests {
		test := test
		t.Run(test.name, func(st *testing.T) {
			st.Parallel()
			err := email.Validate(test.em)
			if err == nil && test.expectErr {
				st.Fatal("expected error, got nil")
			}
			if err != nil && !test.expectErr {
				st.Fatal(err)
			}
		})
	}
}
