github.com/go-email-validator/go-email-validator@v0.0.0-20230409163946-b8b9e6a0552e/pkg/presentation/as-email-verifier/dep_functional_test.go (about)

     1  package asemailverifier
     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/evmail"
     7  	"github.com/go-email-validator/go-email-validator/pkg/ev/evtests"
     8  	"github.com/go-email-validator/go-email-validator/pkg/presentation/converter"
     9  	"github.com/go-email-validator/go-email-validator/pkg/presentation/test"
    10  	"reflect"
    11  	"testing"
    12  )
    13  
    14  func TestMain(m *testing.M) {
    15  	evtests.TestMain(m)
    16  }
    17  
    18  func TestDepConverter_Convert(t *testing.T) {
    19  	evtests.FunctionalSkip(t)
    20  
    21  	validator := NewDepValidator(nil)
    22  	d := NewDepConverterDefault()
    23  
    24  	tests := make([]DepPresentation, 0)
    25  	test.DepPresentations(t, &tests, "")
    26  	// Some data or functional cannot be matched, see more nearby DepPresentation of emails
    27  	skipEmail := hashset.New(
    28  		// todo disposable verification
    29  		"derduzikne@nedoz.com",
    30  		// TODO change presenter, if there is error before mail stage then smtp is nil
    31  		"salestrade86@hotmail.com",
    32  		"monicaramirezrestrepo@hotmail.com",
    33  		"theofanisgiotis@12pm.gr",
    34  		"theofanis.giot2is@12pm.gr",
    35  		"admin@huntgear.ru",
    36  	)
    37  
    38  	opts := converter.NewOptions(0)
    39  	for _, tt := range tests {
    40  		tt := tt
    41  		if skipEmail.Contains(tt.Email) {
    42  			t.Logf("skipped %v", tt.Email)
    43  			continue
    44  		}
    45  		t.Run(tt.Email, func(t *testing.T) {
    46  			t.Parallel()
    47  			email := evmail.FromString(tt.Email)
    48  
    49  			resultValidator := validator.Validate(ev.NewInput(email))
    50  			got := d.Convert(email, resultValidator, opts)
    51  
    52  			if !reflect.DeepEqual(got, tt) {
    53  				t.Errorf("Convert()\n%#v, \n want\n%#v", got, tt)
    54  			}
    55  		})
    56  	}
    57  }