Skip to content

Commit

Permalink
Merge pull request #19 from telia-oss/fix-user-data-tests
Browse files Browse the repository at this point in the history
Fix user data tests
  • Loading branch information
Kristian authored Jul 23, 2019
2 parents 078ff46 + fd32727 commit 62378d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions test/asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Expectations struct {
MinSize int64
MaxSize int64
DesiredCapacity int64
UserData string
UserData []string
InstanceType string
Volumes []string
InstanceTags map[string]string
Expand All @@ -38,7 +38,11 @@ func RunTestSuite(t *testing.T, name, region string, expected Expectations) {
assert.Equal(t, expected.DesiredCapacity, aws.Int64Value(group.DesiredCapacity))

config = DescribeLaunchConfiguration(t, sess, aws.StringValue(group.LaunchConfigurationName))
assert.Equal(t, expected.UserData, DecodeUserData(t, config.UserData))

userData := DecodeUserData(t, config.UserData)
for _, data := range expected.UserData {
assert.Contains(t, userData, data)
}

// Wait for capacity in the autoscaling group (max 10min wait)
WaitForCapacity(t, sess, name, 10*time.Second, 10*time.Minute)
Expand Down
2 changes: 1 addition & 1 deletion test/asg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestDefaultExample(t *testing.T) {
MinSize: 2,
MaxSize: 4,
DesiredCapacity: 2,
UserData: "#!bin/bash\necho hello world",
UserData: []string{"#!bin/bash\necho hello world"},
InstanceType: "t3.micro",
Volumes: []string{
"/dev/xvdcz",
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ variable "instance_policy" {
"NotResource": "*"
}
]
}
EOF
}

0 comments on commit 62378d4

Please sign in to comment.