-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Background and Links * The `load()` method was an interesting experiment but I expect `push()` to be the real workhorse for now * I recently came to suspect that locals, variables, and outputs could be scoped very similarly to everything else ### Changes and Testing * Add some unit tests * Remove `HeliStack.load()`, `HeliStack.Local()`, `HeliStack.Output()`, and `HeliStack.Variable()` * Make `HeliStack.push()` work for `TerraformLocal`, `TerraformOutput`, and `TerraformVariable` * Name the scoping Constructs like provider documentation and plan and apply output
- Loading branch information
Showing
8 changed files
with
73 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,38 @@ | ||
"""Test the helicopyter module.""" | ||
|
||
from unittest import TestCase | ||
|
||
import pytest | ||
from cdktf_cdktf_provider_null.resource import Resource | ||
from cdktf import TerraformLocal, TerraformOutput, TerraformVariable | ||
from cdktf_cdktf_provider_null.resource import Resource as NullResource | ||
from pytest import raises | ||
|
||
from helicopyter import HeliStack | ||
|
||
|
||
class TestHeliStack(TestCase): | ||
def test_load(self) -> None: | ||
"""Multiple calls should work if and only if the id_ string is unique.""" | ||
stack = HeliStack('foo') | ||
NullResource = stack.load('null_resource') # noqa: N806 | ||
my_first_null = NullResource('bar') | ||
assert isinstance(my_first_null, Resource) | ||
|
||
my_second_null = NullResource('baz') | ||
assert isinstance(my_second_null, Resource) | ||
def test_helistack() -> None: | ||
"""The class must instantiate and provide the cona attribute and provide and push methods.""" | ||
stack = HeliStack('foo') | ||
assert stack.cona == 'foo' | ||
assert callable(stack.provide) | ||
assert callable(stack.push) | ||
|
||
with pytest.raises(RuntimeError): | ||
NullResource('bar') | ||
|
||
with pytest.raises(RuntimeError): | ||
stack.push(Resource, 'bar') | ||
def test_push_id() -> None: | ||
"""Within a given Element such as the NullResource, the id_ must be unique.""" | ||
stack = HeliStack('foo') | ||
my_first_null = stack.push(NullResource, 'bar') | ||
assert isinstance(my_first_null, NullResource) | ||
|
||
def test_push(self) -> None: | ||
"""Multiple calls should work if and only if the id_ string is unique.""" | ||
stack = HeliStack('foo') | ||
my_first_null = stack.push(Resource, 'bar') | ||
assert isinstance(my_first_null, Resource) | ||
my_second_null = stack.push(NullResource, 'baz') | ||
assert isinstance(my_second_null, NullResource) | ||
|
||
my_second_null = stack.push(Resource, 'baz') | ||
assert isinstance(my_second_null, Resource) | ||
with raises(RuntimeError): | ||
stack.push(NullResource, 'bar') | ||
|
||
with pytest.raises(RuntimeError): | ||
stack.push(Resource, 'bar') | ||
|
||
with pytest.raises(RuntimeError): | ||
stack.load('null_resource')('bar') | ||
def test_push_provider() -> None: | ||
"""The same id_ must be allowed for different Elements.""" | ||
stack = HeliStack('foo') | ||
stack.push(NullResource, 'bar') | ||
stack.push(TerraformLocal, 'bar', 'bar') | ||
stack.push(TerraformOutput, 'bar', value='bar') | ||
stack.push(TerraformVariable, 'bar') | ||
stack.to_terraform() |