File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,6 @@ function aws_wrapper_get_ips_with_tag {
179179
180180 local instances
181181 instances=$( aws_get_instances_with_tag " $tag_key " " $tag_value " " $aws_region " )
182- assert_not_empty_or_null " $instances " " Get info about Instances with tag $tag_key set to $tag_value "
183182
184183 local readonly ip_param=$( [[ " $use_public_ips " == " true" ]] && echo " PublicIpAddress" || echo " PrivateIpAddress" )
185184 echo " $instances " | jq -r " .Reservations[].Instances[].$ip_param "
Original file line number Diff line number Diff line change @@ -121,4 +121,32 @@ END_HEREDOC
121121 local num_instances
122122 num_instances=$( echo " $output " | jq -r ' .Reservations | length' )
123123 assert_greater_than " $num_instances " 0
124- }
124+ }
125+
126+ @test " aws_get_instances_with_tag empty" {
127+ run aws_get_instances_with_tag " Name" " Value" " us-east-1"
128+ assert_success
129+
130+ local readonly expected=$( cat << END_HEREDOC
131+ {
132+ "Reservations": []
133+ }
134+ END_HEREDOC
135+ )
136+
137+ assert_output_json " $expected "
138+ }
139+
140+ @test " aws_get_instances_with_tag non-empty" {
141+ local -r tag_key=" Name"
142+ local -r tag_value=" Value"
143+ local -r region=" us-east-1"
144+
145+ create_mock_instance_with_tags " $tag_key " " $tag_value "
146+ run aws_get_instances_with_tag " $tag_key " " $tag_value " " $region "
147+ assert_success
148+
149+ local num_instances
150+ num_instances=$( echo " $output " | jq -r ' .Reservations | length' )
151+ assert_greater_than " $num_instances " 0
152+ }
You can’t perform that action at this time.
0 commit comments