diff --git a/image/src/github_pr_comment/plan_formatting.py b/image/src/github_pr_comment/plan_formatting.py index 8f5eac7e..28a8de6e 100644 --- a/image/src/github_pr_comment/plan_formatting.py +++ b/image/src/github_pr_comment/plan_formatting.py @@ -23,7 +23,7 @@ def format_diff(plan_text: str) -> str: count=1 )) - replaced = replaced.replace('~', '!') + replaced = replaced.replace('~ ', '!~') replaced = re.sub( r'(?P\s+)\# (?P\(.*hidden)', diff --git a/tests/test_diff_formatting.py b/tests/test_diff_formatting.py index 510fc2bb..2da3a170 100644 --- a/tests/test_diff_formatting.py +++ b/tests/test_diff_formatting.py @@ -82,7 +82,7 @@ def test_diff(): expected = ''' Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create -! update in-place +!~ update in-place - destroy -/+ destroy and then create replacement +/- create replacement and then destroy @@ -90,8 +90,8 @@ def test_diff(): Terraform will perform the following actions: # aws_s3_object.update will be updated in-place -! resource "aws_s3_object" "update" { -! content = "hello" -> "update" +!~ resource "aws_s3_object" "update" { +!~ content = "hello" -> "update" id = "test-plan-colours-test-object" tags = {} + version_id = (known after apply) @@ -116,9 +116,9 @@ def test_diff(): # random_string.create_before_delete must be replaced +/- resource "random_string" "create_before_delete" { -! id = "BW8p" -> (known after apply) -! length = 4 -> 3 # forces replacement -! result = "BW8p" -> (known after apply) +!~ id = "BW8p" -> (known after apply) +!~ length = 4 -> 3 # forces replacement +!~ result = "BW8p" -> (known after apply) # (9 unchanged attributes hidden) } @@ -141,9 +141,9 @@ def test_diff(): # random_string.delete_before_create must be replaced -/+ resource "random_string" "delete_before_create" { -! id = "S@M" -> (known after apply) -! length = 3 -> 4 # forces replacement -! result = "S@M" -> (known after apply) +!~ id = "S@M" -> (known after apply) +!~ length = 3 -> 4 # forces replacement +!~ result = "S@M" -> (known after apply) # (9 unchanged attributes hidden) } @@ -152,7 +152,7 @@ def test_diff(): Changes to Outputs: + add = "hello" - delete = "goodbye" -> null -! update = "hello" -> "update" +!~ update = "hello" -> "update" ''' print(format_diff(plan)) @@ -230,7 +230,7 @@ def test_heredoc(): - destroy -/+ destroy and then create replacement +/- create replacement and then destroy -! update in-place +!~ update in-place Terraform will perform the following actions: @@ -287,4 +287,5 @@ def test_heredoc(): Plan: 3 to add, 1 to change, 3 to destroy.''' + print(format_diff(plan)) assert format_diff(plan) == expected \ No newline at end of file