github.com/aavshr/aws-sdk-go@v1.41.3/service/cloudformation/integ_test.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  //go:build go1.16 && integration
     4  // +build go1.16,integration
     5  
     6  package cloudformation_test
     7  
     8  import (
     9  	"context"
    10  	"testing"
    11  	"time"
    12  
    13  	"github.com/aavshr/aws-sdk-go/aws"
    14  	"github.com/aavshr/aws-sdk-go/aws/awserr"
    15  	"github.com/aavshr/aws-sdk-go/aws/request"
    16  	"github.com/aavshr/aws-sdk-go/awstesting/integration"
    17  	"github.com/aavshr/aws-sdk-go/service/cloudformation"
    18  )
    19  
    20  var _ aws.Config
    21  var _ awserr.Error
    22  var _ request.Request
    23  
    24  func TestInteg_00_ListStacks(t *testing.T) {
    25  	ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
    26  	defer cancelFn()
    27  
    28  	sess := integration.SessionWithDefaultRegion("us-west-2")
    29  	svc := cloudformation.New(sess)
    30  	params := &cloudformation.ListStacksInput{}
    31  	_, err := svc.ListStacksWithContext(ctx, params, func(r *request.Request) {
    32  		r.Handlers.Validate.RemoveByName("core.ValidateParametersHandler")
    33  	})
    34  	if err != nil {
    35  		t.Errorf("expect no error, got %v", err)
    36  	}
    37  }
    38  func TestInteg_01_CreateStack(t *testing.T) {
    39  	ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
    40  	defer cancelFn()
    41  
    42  	sess := integration.SessionWithDefaultRegion("us-west-2")
    43  	svc := cloudformation.New(sess)
    44  	params := &cloudformation.CreateStackInput{
    45  		StackName:   aws.String("fakestack"),
    46  		TemplateURL: aws.String("http://s3.amazonaws.com/foo/bar"),
    47  	}
    48  	_, err := svc.CreateStackWithContext(ctx, params, func(r *request.Request) {
    49  		r.Handlers.Validate.RemoveByName("core.ValidateParametersHandler")
    50  	})
    51  	if err == nil {
    52  		t.Fatalf("expect request to fail")
    53  	}
    54  	aerr, ok := err.(awserr.RequestFailure)
    55  	if !ok {
    56  		t.Fatalf("expect awserr, was %T", err)
    57  	}
    58  	if len(aerr.Code()) == 0 {
    59  		t.Errorf("expect non-empty error code")
    60  	}
    61  	if len(aerr.Message()) == 0 {
    62  		t.Errorf("expect non-empty error message")
    63  	}
    64  	if v := aerr.Code(); v == request.ErrCodeSerialization {
    65  		t.Errorf("expect API error code got serialization failure")
    66  	}
    67  }