github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/modules/aws/ecs_test.go (about) 1 package aws 2 3 import ( 4 "testing" 5 6 "github.com/aws/aws-sdk-go/aws" 7 "github.com/aws/aws-sdk-go/service/ecs" 8 "github.com/gruntwork-io/terratest/modules/random" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestEcsCluster(t *testing.T) { 13 t.Parallel() 14 15 region := GetRandomStableRegion(t, nil, nil) 16 c1, err := CreateEcsClusterE(t, region, "terratest") 17 defer DeleteEcsCluster(t, region, c1) 18 19 assert.Nil(t, err) 20 assert.Equal(t, "terratest", *c1.ClusterName) 21 22 c2, err := GetEcsClusterE(t, region, *c1.ClusterName) 23 24 assert.Nil(t, err) 25 assert.Equal(t, "terratest", *c2.ClusterName) 26 } 27 28 func TestEcsClusterWithInclude(t *testing.T) { 29 t.Parallel() 30 31 region := GetRandomStableRegion(t, nil, nil) 32 clusterName := "terratest-" + random.UniqueId() 33 tags := []*ecs.Tag{&ecs.Tag{ 34 Key: aws.String("test-tag"), 35 Value: aws.String("hello-world"), 36 }} 37 38 client := NewEcsClient(t, region) 39 c1, err := client.CreateCluster(&ecs.CreateClusterInput{ 40 ClusterName: aws.String(clusterName), 41 Tags: tags, 42 }) 43 assert.NoError(t, err) 44 45 defer DeleteEcsCluster(t, region, c1.Cluster) 46 47 assert.Equal(t, clusterName, aws.StringValue(c1.Cluster.ClusterName)) 48 49 c2, err := GetEcsClusterWithIncludeE(t, region, clusterName, []string{ecs.ClusterFieldTags}) 50 assert.NoError(t, err) 51 52 assert.Equal(t, clusterName, aws.StringValue(c2.ClusterName)) 53 assert.Equal(t, tags, c2.Tags) 54 assert.Empty(t, c2.Statistics) 55 56 c3, err := GetEcsClusterWithIncludeE(t, region, clusterName, []string{ecs.ClusterFieldStatistics}) 57 assert.NoError(t, err) 58 59 assert.Equal(t, clusterName, aws.StringValue(c3.ClusterName)) 60 assert.NotEmpty(t, c3.Statistics) 61 assert.Empty(t, c3.Tags) 62 }