github.com/aavshr/aws-sdk-go@v1.41.3/service/cloudsearchdomain/customizations_test.go (about) 1 package cloudsearchdomain_test 2 3 import ( 4 "testing" 5 6 "github.com/aavshr/aws-sdk-go/aws" 7 "github.com/aavshr/aws-sdk-go/awstesting/unit" 8 "github.com/aavshr/aws-sdk-go/service/cloudsearchdomain" 9 ) 10 11 func TestRequireEndpointIfRegionProvided(t *testing.T) { 12 svc := cloudsearchdomain.New(unit.Session, &aws.Config{ 13 Region: aws.String("mock-region"), 14 DisableParamValidation: aws.Bool(true), 15 }) 16 req, _ := svc.SearchRequest(nil) 17 err := req.Build() 18 19 if e, a := "", svc.Endpoint; e != a { 20 t.Errorf("expect %v, got %v", e, a) 21 } 22 if err == nil { 23 t.Errorf("expect error, got none") 24 } 25 if e, a := aws.ErrMissingEndpoint, err; e != a { 26 t.Errorf("expect %v, got %v", e, a) 27 } 28 } 29 30 func TestRequireEndpointIfNoRegionProvided(t *testing.T) { 31 svc := cloudsearchdomain.New(unit.Session, &aws.Config{ 32 DisableParamValidation: aws.Bool(true), 33 }) 34 req, _ := svc.SearchRequest(nil) 35 err := req.Build() 36 37 if e, a := "", svc.Endpoint; e != a { 38 t.Errorf("expect %v, got %v", e, a) 39 } 40 if err == nil { 41 t.Errorf("expect error, got none") 42 } 43 if e, a := aws.ErrMissingEndpoint, err; e != a { 44 t.Errorf("expect %v, got %v", e, a) 45 } 46 } 47 48 func TestRequireEndpointUsed(t *testing.T) { 49 svc := cloudsearchdomain.New(unit.Session, &aws.Config{ 50 Region: aws.String("mock-region"), 51 DisableParamValidation: aws.Bool(true), 52 Endpoint: aws.String("https://endpoint"), 53 }) 54 req, _ := svc.SearchRequest(nil) 55 err := req.Build() 56 57 if e, a := "https://endpoint", svc.Endpoint; e != a { 58 t.Errorf("expect %v, got %v", e, a) 59 } 60 if err != nil { 61 t.Errorf("expect no error, got %v", err) 62 } 63 }