github.com/webonyx/up@v0.7.4-0.20180808230834-91b94e551323/platform/lambda/stack/stack_test.go (about) 1 package stack 2 3 import ( 4 "testing" 5 6 "github.com/aws/aws-sdk-go/aws" 7 "github.com/aws/aws-sdk-go/service/cloudformation" 8 "github.com/tj/assert" 9 ) 10 11 func TestResourcesCompleted(t *testing.T) { 12 resources := []*cloudformation.StackResource{ 13 { 14 LogicalResourceId: aws.String("DnsZoneSomethingComRecordApiSomethingCom"), 15 PhysicalResourceId: aws.String("api.something.com"), 16 ResourceStatus: aws.String("CREATE_IN_PROGRESS"), 17 ResourceStatusReason: aws.String("Resource creation Initiated"), 18 ResourceType: aws.String("AWS::Route53::RecordSet"), 19 StackId: aws.String("arn:aws:cloudformation:us-west-2:foobarbaz:stack/app/ad3af570-8511-11e7-8832-50d5ca789e4a"), 20 StackName: aws.String("app"), 21 }, 22 { 23 LogicalResourceId: aws.String("ApiProxyMethod"), 24 PhysicalResourceId: aws.String("app-ApiProx-33K7PKBL7HNI"), 25 ResourceStatus: aws.String("CREATE_COMPLETE"), 26 ResourceType: aws.String("AWS::ApiGateway::Method"), 27 StackId: aws.String("arn:aws:cloudformation:us-west-2:foobarbaz:stack/app/ad3af570-8511-11e7-8832-50d5ca789e4a"), 28 StackName: aws.String("app"), 29 }, 30 { 31 LogicalResourceId: aws.String("Another"), 32 ResourceStatus: aws.String("CREATE_COMPLETE"), 33 ResourceType: aws.String("AWS::ApiGateway::Method"), 34 StackId: aws.String("arn:aws:cloudformation:us-west-2:foobarbaz:stack/app/ad3af570-8511-11e7-8832-50d5ca789e4a"), 35 StackName: aws.String("app"), 36 }, 37 } 38 39 states := map[string]Status{ 40 "DnsZoneSomethingComRecordApiSomethingCom": CreateComplete, 41 "app-ApiProx-33K7PKBL7HNI": CreateComplete, 42 } 43 44 c := resourcesCompleted(resources, states) 45 assert.Len(t, c, 1) 46 }