customizations_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package iotdataplane_test
  2. import (
  3. "fmt"
  4. "github.com/stretchr/testify/assert"
  5. "testing"
  6. "github.com/aws/aws-sdk-go/aws"
  7. "github.com/aws/aws-sdk-go/awstesting/unit"
  8. "github.com/aws/aws-sdk-go/service/iotdataplane"
  9. )
  10. func TestRequireEndpointIfRegionProvided(t *testing.T) {
  11. svc := iotdataplane.New(unit.Session, &aws.Config{
  12. Region: aws.String("mock-region"),
  13. DisableParamValidation: aws.Bool(true),
  14. })
  15. req, _ := svc.GetThingShadowRequest(nil)
  16. err := req.Build()
  17. assert.Equal(t, "", svc.Endpoint)
  18. assert.Error(t, err)
  19. assert.Equal(t, aws.ErrMissingEndpoint, err)
  20. }
  21. func TestRequireEndpointIfNoRegionProvided(t *testing.T) {
  22. svc := iotdataplane.New(unit.Session, &aws.Config{
  23. Region: aws.String(""),
  24. DisableParamValidation: aws.Bool(true),
  25. })
  26. fmt.Println(svc.ClientInfo.SigningRegion)
  27. req, _ := svc.GetThingShadowRequest(nil)
  28. err := req.Build()
  29. assert.Equal(t, "", svc.Endpoint)
  30. assert.Error(t, err)
  31. assert.Equal(t, aws.ErrMissingEndpoint, err)
  32. }
  33. func TestRequireEndpointUsed(t *testing.T) {
  34. svc := iotdataplane.New(unit.Session, &aws.Config{
  35. Region: aws.String("mock-region"),
  36. DisableParamValidation: aws.Bool(true),
  37. Endpoint: aws.String("https://endpoint"),
  38. })
  39. req, _ := svc.GetThingShadowRequest(nil)
  40. err := req.Build()
  41. assert.Equal(t, "https://endpoint", svc.Endpoint)
  42. assert.NoError(t, err)
  43. }