customizations_test.go 1.6 KB

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