Skip to content

Commit 1c4aece

Browse files
authored
Merge pull request #31 from CallyCo-io/fix/write-template
fix: Write Terraform
2 parents eb864c5 + cfa750c commit 1c4aece

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/cally/cli/commands/tf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def print_template(config: CallyStackServiceConfig):
1818
click.secho(action.print())
1919

2020

21-
@click.command(name='write')
21+
@click.command(name='write', cls=CallyStackServiceCommand())
2222
@click.option(
2323
'--output',
2424
type=click.Path(path_type=Path),

tests/cli/test_tf.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
from pathlib import Path
34
from unittest import mock
45

56
from click.testing import CliRunner
@@ -23,3 +24,25 @@ def test_empty_print(self):
2324
json.loads(result.output).get('terraform'),
2425
testdata,
2526
)
27+
28+
@mock.patch.dict(os.environ, {"CALLY_STACK_TYPE": "CallyStack"})
29+
def test_empty_write(self):
30+
data = Path(self.working.name, 'cdk.tf.json')
31+
result = CliRunner().invoke(
32+
tf,
33+
[
34+
'write',
35+
'--service',
36+
'test',
37+
'--environment',
38+
'test',
39+
'--output',
40+
data.as_posix(),
41+
],
42+
)
43+
self.assertEqual(result.exit_code, 0)
44+
testdata = {"backend": {"local": {"path": "state/test/test"}}}
45+
self.assertDictEqual(
46+
json.loads(data.read_text(encoding='utf8')).get('terraform'),
47+
testdata,
48+
)

0 commit comments

Comments
 (0)