Skip to content

Commit

Permalink
test: Generalise Empty Synth test
Browse files Browse the repository at this point in the history
There isn't a strong need to test a full json payload. This avoids issues when
the cdktf version changes
  • Loading branch information
techman83 committed Mar 18, 2024
1 parent 4c7295a commit 4c21821
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
6 changes: 4 additions & 2 deletions tests/cli/test_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class TfTests(CallyTestHarness):
def test_empty_print(self):
result = CliRunner().invoke(
tf,
['print', '--service', 'test-cli', '--environment', 'test'],
['print', '--service', 'test', '--environment', 'test'],
obj=CallyConfig(config_file='blah.yaml'),
)
self.assertEqual(result.exit_code, 0)
testdata = {"backend": {"local": {"path": "state/test.tfstate"}}}
self.assertDictEqual(
json.loads(result.output), self.load_json_file('cli/empty_print.json')
json.loads(result.output).get('terraform'),
testdata,
)
4 changes: 3 additions & 1 deletion tests/stacks/test_cally.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ class CallyStackTests(CallyTfTestHarness):
def test_empty_synth(self):
stack = CallyStack(service=self.empty_service)
result = self.synth_stack(stack)
self.assertDictEqual(result, self.load_json_file('cdk/empty_synth.json'))
self.assertDictEqual(
result.get('terraform'), self.load_json_file('cdk/empty_synth.json')
)
4 changes: 3 additions & 1 deletion tests/stacks/test_idp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ def test_class_load(self):
def test_empty_synth(self):
stack = stacks.MinimalStack(service=self.empty_service)
result = self.synth_stack(stack)
self.assertDictEqual(result, self.load_json_file('cdk/empty_synth.json'))
self.assertDictEqual(
result.get('terraform'), self.load_json_file('cdk/empty_synth.json')
)
16 changes: 3 additions & 13 deletions tests/testdata/cdk/empty_synth.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"//": {
"metadata": {
"backend": "local",
"stackName": "test",
"version": "0.20.4"
},
"outputs": {}
},
"terraform": {
"backend": {
"local": {
"path": "state/test.tfstate"
}
"backend": {
"local": {
"path": "state/test.tfstate"
}
}
}

0 comments on commit 4c21821

Please sign in to comment.