integ_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. // +build go1.10,integration
  3. package elasticsearchservice_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/elasticsearchservice"
  13. )
  14. var _ aws.Config
  15. var _ awserr.Error
  16. var _ request.Request
  17. func TestInteg_00_ListDomainNames(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 := elasticsearchservice.New(sess)
  22. params := &elasticsearchservice.ListDomainNamesInput{}
  23. _, err := svc.ListDomainNamesWithContext(ctx, params)
  24. if err != nil {
  25. t.Errorf("expect no error, got %v", err)
  26. }
  27. }
  28. func TestInteg_01_DescribeElasticsearchDomain(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 := elasticsearchservice.New(sess)
  33. params := &elasticsearchservice.DescribeElasticsearchDomainInput{
  34. DomainName: aws.String("not-a-domain"),
  35. }
  36. _, err := svc.DescribeElasticsearchDomainWithContext(ctx, params)
  37. if err == nil {
  38. t.Fatalf("expect request to fail")
  39. }
  40. aerr, ok := err.(awserr.RequestFailure)
  41. if !ok {
  42. t.Fatalf("expect awserr, was %T", err)
  43. }
  44. if len(aerr.Code()) == 0 {
  45. t.Errorf("expect non-empty error code")
  46. }
  47. if v := aerr.Code(); v == request.ErrCodeSerialization {
  48. t.Errorf("expect API error code got serialization failure")
  49. }
  50. }