integ_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. // +build go1.10,integration
  3. package sns_test
  4. import (
  5. "context"
  6. "testing"
  7. "time"
  8. "github.com/aws/aws-sdk-go/aws"
  9. "github.com/aws/aws-sdk-go/aws/awserr"
  10. "github.com/aws/aws-sdk-go/aws/request"
  11. "github.com/aws/aws-sdk-go/awstesting/integration"
  12. "github.com/aws/aws-sdk-go/service/sns"
  13. )
  14. var _ aws.Config
  15. var _ awserr.Error
  16. var _ request.Request
  17. func TestInteg_00_ListTopics(t *testing.T) {
  18. ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
  19. defer cancelFn()
  20. sess := integration.SessionWithDefaultRegion("us-west-2")
  21. svc := sns.New(sess)
  22. params := &sns.ListTopicsInput{}
  23. _, err := svc.ListTopicsWithContext(ctx, params)
  24. if err != nil {
  25. t.Errorf("expect no error, got %v", err)
  26. }
  27. }
  28. func TestInteg_01_Publish(t *testing.T) {
  29. ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
  30. defer cancelFn()
  31. sess := integration.SessionWithDefaultRegion("us-west-2")
  32. svc := sns.New(sess)
  33. params := &sns.PublishInput{
  34. Message: aws.String("hello"),
  35. TopicArn: aws.String("fake_topic"),
  36. }
  37. _, err := svc.PublishWithContext(ctx, params)
  38. if err == nil {
  39. t.Fatalf("expect request to fail")
  40. }
  41. aerr, ok := err.(awserr.RequestFailure)
  42. if !ok {
  43. t.Fatalf("expect awserr, was %T", err)
  44. }
  45. if len(aerr.Code()) == 0 {
  46. t.Errorf("expect non-empty error code")
  47. }
  48. if v := aerr.Code(); v == request.ErrCodeSerialization {
  49. t.Errorf("expect API error code got serialization failure")
  50. }
  51. }