github.com/go-email-validator/go-email-validator@v0.0.0-20230409163946-b8b9e6a0552e/pkg/presentation/mailboxvalidator/dep_view_functional_test.go (about) 1 package mailboxvalidator 2 3 import ( 4 "github.com/emirpasic/gods/sets/hashset" 5 "github.com/go-email-validator/go-email-validator/pkg/ev" 6 "github.com/go-email-validator/go-email-validator/pkg/ev/evtests" 7 "github.com/go-email-validator/go-email-validator/pkg/presentation/converter" 8 "github.com/go-email-validator/go-email-validator/pkg/presentation/test" 9 "reflect" 10 "testing" 11 ) 12 13 func TestMain(m *testing.M) { 14 evtests.TestMain(m) 15 } 16 17 func TestDepConverter_Functional_Convert(t *testing.T) { 18 evtests.FunctionalSkip(t) 19 20 validator := NewDepValidator(nil) 21 d := NewDepConverterForViewDefault() 22 23 tests := detPresentersFoView(t) 24 25 // Some data or functional cannot be matched, see more nearby DepPresentation of emails 26 skipEmail := hashset.New( 27 "zxczxczxc@joycasinoru", // TODO syntax is valid 28 "sewag33689@itymail.com", 29 "derduzikne@nedoz.com", 30 "tvzamhkdc@emlhub.com", 31 "admin@gmail.com", 32 "salestrade86@hotmail.com", 33 "monicaramirezrestrepo@hotmail.com", 34 "y-numata@senko.ed.jp", 35 "pr@yandex-team.ru", 36 "asdasd@tradepro.net", 37 "theofanisgiotis@12pm.gr", 38 "theofanis.giot2is@12pm.gr", 39 "admin@huntgear.ru", 40 ) 41 42 for _, tt := range tests { 43 tt := tt 44 if skipEmail.Contains(tt.EmailAddress) { 45 t.Logf("skipped %v", tt.EmailAddress) 46 continue 47 } 48 49 t.Run(tt.EmailAddress, func(t *testing.T) { 50 t.Parallel() 51 52 email := EmailFromString(tt.EmailAddress) 53 54 opts := converter.NewOptions(0) 55 tt.TimeTaken = "0" 56 57 resultValidator := validator.Validate(ev.NewInput(email)) 58 if gotResult := d.Convert(email, resultValidator, opts); !reflect.DeepEqual(gotResult, tt) { 59 t.Errorf("Convert()\n%#v, \n want\n%#v", gotResult, tt) 60 } 61 }) 62 } 63 } 64 65 func detPresenters(t *testing.T) []DepPresentation { 66 tests := make([]DepPresentation, 0) 67 test.DepPresentations(t, &tests, "") 68 69 return tests 70 } 71 72 func detPresentersFoView(t *testing.T) []DepPresentationForView { 73 tests := make([]DepPresentationForView, 0) 74 test.DepPresentations(t, &tests, "dep_view_fixture_test.json") 75 76 return tests 77 }