customizations_test.go 1.6 KB

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