Skip to content

Commit 19c0cc5

Browse files
committed
Updated tests to separate new functionality
1 parent 553f923 commit 19c0cc5

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

tests/command.bats

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ expected_container_definition='[\n {\n "essential": true,\n "image": "hel
5252
export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_FAMILY=hello-world
5353
export BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_0=hello-world:llamas
5454
export BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_1=hello-world:alpacas
55-
export BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_0="FOO=bar"
56-
export BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_1="BAZ=bing"
5755

5856
export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION=examples/multiple-images.json
5957

@@ -80,6 +78,45 @@ expected_container_definition='[\n {\n "essential": true,\n "image": "hel
8078
unset BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_1
8179
}
8280

81+
@test "Add env vars on multiple images" {
82+
export BUILDKITE_BUILD_NUMBER=1
83+
export BUILDKITE_PLUGIN_ECS_DEPLOY_CLUSTER=my-cluster
84+
export BUILDKITE_PLUGIN_ECS_DEPLOY_SERVICE=my-service
85+
export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_FAMILY=hello-world
86+
export BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_0=hello-world:llamas
87+
export BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_1=hello-world:alpacas
88+
export BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_0="FOO=bar"
89+
export BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_1="BAZ=bing"
90+
91+
export BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION=examples/multiple-images.json
92+
93+
# first command stubbed saves the container definition to ${_TMP_DIR}/container_definition for later review and manipulation
94+
stub aws \
95+
"ecs register-task-definition --family hello-world --container-definitions '*' : echo \"\$6\" > ${_TMP_DIR}/container_definition ; echo '{\"taskDefinition\":{\"revision\":1}}'"
96+
97+
run "$PWD/hooks/command"
98+
99+
# there is no assert_success because we are just checking that the definition was updated accordingly
100+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[0].environment[0].name') 'FOO'
101+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[0].environment[0].value') 'bar'
102+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[1].environment[0].name') 'FOO'
103+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[1].environment[0].value') 'bar'
104+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[0].environment[1].name') 'BAZ'
105+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[0].environment[1].value') 'bing'
106+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[1].environment[1].name') 'BAZ'
107+
assert_equal $(cat ${_TMP_DIR}/container_definition | jq -r '.[1].environment[1].value') 'bing'
108+
109+
# as the aws command is called more times than stubbed, it is unstubbed automatically
110+
# unstub aws
111+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_CLUSTER
112+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_SERVICE
113+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_TASK_DEFINITION
114+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_0
115+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_IMAGE_1
116+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_0
117+
unset BUILDKITE_PLUGIN_ECS_DEPLOY_ENV_1
118+
}
119+
83120
@test "Run a deploy when service does not exist" {
84121
export BUILDKITE_BUILD_NUMBER=1
85122
export BUILDKITE_PLUGIN_ECS_DEPLOY_CLUSTER=my-cluster

0 commit comments

Comments
 (0)