Skip to content

Commit

Permalink
fix: Write Terraform
Browse files Browse the repository at this point in the history
During the refactor, a class for the write command was missed. Fixed
the command and added a test to ensure it won't be missed in future
changes
  • Loading branch information
techman83 committed Nov 11, 2024
1 parent eb864c5 commit cfa750c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cally/cli/commands/tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def print_template(config: CallyStackServiceConfig):
click.secho(action.print())


@click.command(name='write')
@click.command(name='write', cls=CallyStackServiceCommand())
@click.option(
'--output',
type=click.Path(path_type=Path),
Expand Down
23 changes: 23 additions & 0 deletions tests/cli/test_tf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
from pathlib import Path
from unittest import mock

from click.testing import CliRunner
Expand All @@ -23,3 +24,25 @@ def test_empty_print(self):
json.loads(result.output).get('terraform'),
testdata,
)

@mock.patch.dict(os.environ, {"CALLY_STACK_TYPE": "CallyStack"})
def test_empty_write(self):
data = Path(self.working.name, 'cdk.tf.json')
result = CliRunner().invoke(
tf,
[
'write',
'--service',
'test',
'--environment',
'test',
'--output',
data.as_posix(),
],
)
self.assertEqual(result.exit_code, 0)
testdata = {"backend": {"local": {"path": "state/test/test"}}}
self.assertDictEqual(
json.loads(data.read_text(encoding='utf8')).get('terraform'),
testdata,
)

0 comments on commit cfa750c

Please sign in to comment.