Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail when resource_changes key not present in output #27

Merged
merged 2 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/fixtures/plan_no_resource_changes/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

output "just_an_output" {
value = "Hello, plan!"
}
7 changes: 7 additions & 0 deletions test/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ def test_modules(plan_out):
def test_child_modules(plan_out):
mod = plan_out.modules['module.parent'].child_modules['module.child']
assert mod.resources['eggs.someeggs']['values']['eggs-value'] == 'eggs'


def test_plan_with_no_resources_succeeds(fixtures_dir):
tf = tftest.TerraformTest('plan_no_resource_changes', fixtures_dir)
result = tf.plan(output=True)

assert result.outputs['just_an_output'] == 'Hello, plan!'
2 changes: 1 addition & 1 deletion tftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __init__(self, raw):
planned_values.get('root_module', {}))
self.outputs = TerraformValueDict(planned_values.get('outputs', {}))
self.resource_changes = dict((v['address'], v)
for v in self._raw['resource_changes'])
for v in self._raw.get('resource_changes', {}))
# there might be no variables defined
self.variables = TerraformValueDict(raw.get('variables', {}))

Expand Down