10000 Refactor CFn conditions & mappings by dominikschubert · Pull Request #8546 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Refactor CFn conditions & mappings #8546

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

Merged
merged 14 commits into from
Jun 28, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup tests
  • Loading branch information
dominikschubert committed Jun 26, 2023
commit 3ebf4b294d162c3e250291a51e546909f0dd801b
33 changes: 10 additions & 23 deletions tests/integration/cloudformation/engine/test_conditions.py
B1EA
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from localstack.testing.aws.util import is_aws_cloud
from localstack.utils.files import load_file
from localstack.utils.strings import short_uid

Expand All @@ -13,18 +14,6 @@ class TestCloudFormationConditions:
TODO: what happens to outputs that reference a resource that isn't deployed?
"""

@pytest.mark.skip(reason="because I say so")
def test_evaluation_order(self, aws_client):
"""
Explore evaluation order of conditions

1. Parameters
2. Macros/Transformations
3. Conditions
4. Intrinsic functions
"""
...

@pytest.mark.aws_validated
def test_simple_condition_evaluation_deploys_resource(
self, aws_client, deploy_cfn_template, cleanups
Expand Down Expand Up @@ -66,6 +55,7 @@ def test_simple_condition_evaluation_doesnt_deploy_resource(
# verify that CloudFormation ignores the resource
aws_client.cloudformation.describe_stack_resources(StackName=deployment.stack_id)
# assert stack_resources['StackResources'] == []
# FIXME: currently broken in localstack

# verify actual resource deployment
assert [
Expand All @@ -74,10 +64,7 @@ def test_simple_condition_evaluation_doesnt_deploy_resource(

@pytest.mark.parametrize(
"should_set_custom_name",
[
# "yep",
"nope"
],
["yep", "nope"],
)
@pytest.mark.aws_validated
def test_simple_intrinsic_fn_condition_evaluation(
Expand All @@ -88,8 +75,8 @@ def test_simple_intrinsic_fn_condition_evaluation(

The conditional ShouldSetCustomName (yep | nope) switches between an autogenerated and a predefined name for the topic

TODO: this also works with the simple-intrinsic-condition-name-conflict.yaml template where the ID of the condition and the ID of the parameter are the same(!).
It is currently broken in LocalStack
TODO: this should also work with the simple-intrinsic-condition-name-conflict.yaml template where the ID of the condition and the ID of the parameter are the same(!).
It is currently broken in LocalStack though
"""
topic_name = f"test-topic-{short_uid()}"
deployment = deploy_cfn_template(
Expand All @@ -109,7 +96,7 @@ def test_simple_intrinsic_fn_condition_evaluation(
assert topic_name not in topic_arn

@pytest.mark.aws_validated
@pytest.mark.skip(reason="because I say so")
@pytest.mark.skipif(condition=not is_aws_cloud(), reason="not supported yet")
def test_dependent_ref(self, aws_client, snapshot):
"""
Tests behavior of a stack with 2 resources where one depends on the other.
Expand Down Expand Up @@ -139,7 +126,7 @@ def test_dependent_ref(self, aws_client, snapshot):
snapshot.match("dependent_ref_exc", e.value.response)

@pytest.mark.aws_validated
@pytest.mark.skip(reason="because I say so")
@pytest.mark.skipif(condition=not is_aws_cloud(), reason="not supported yet")
def test_dependent_ref_intrinsic_fn_condition(self, aws_client, deploy_cfn_template):
"""
Checks behavior of un-refable
Expand All @@ -159,7 +146,7 @@ def test_dependent_ref_intrinsic_fn_condition(self, aws_client, deploy_cfn_templ
)

@pytest.mark.aws_validated
@pytest.mark.skip(reason="because I say so")
@pytest.mark.skipif(condition=not is_aws_cloud(), reason="not supported yet")
def test_dependent_ref_with_macro(
self, aws_client, deploy_cfn_template, lambda_su_role, cleanups
):
Expand Down Expand Up @@ -220,7 +207,6 @@ def test_dependent_ref_with_macro(
# param = aws_client.ssm.get_parameter(Name=ssm_param_name)
# assert param['Parameter']['Value']

# TODO: implement
@pytest.mark.parametrize(
["env_type", "should_create_bucket", "should_create_policy"],
[
Expand All @@ -236,7 +222,8 @@ def test_dependent_ref_with_macro(
"prod-bucket-policy",
],
)
@pytest.mark.skip(reason="because I say so")
@pytest.mark.skipif(condition=not is_aws_cloud(), reason="not supported yet")
@pytest.mark.aws_validated
def test_nested_conditions(
self,
aws_client,
Expand Down
0