From 4cc5cf68487ffac04843b54df312eb96d4db536c Mon Sep 17 00:00:00 2001 From: Volodymyr Stupnytskyi <114562693+VladimirSt-XP@users.noreply.github.com> Date: Fri, 4 Nov 2022 18:19:39 +0200 Subject: [PATCH] Updating diffKeywordRegex to properly handle new test case (#2551) * new resource was added to test TestRenderProjectResultsWithEnableDiffMarkdownFormat * Correct test case * 1st regex change * Adding one more pattern to regex Co-authored-by: dyurovskykh-tivo --- server/events/markdown_renderer_test.go | 74 ++++++++++++++++++++++++- server/events/models/models.go | 2 +- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go index 44d64ddcb..779bc546d 100644 --- a/server/events/markdown_renderer_test.go +++ b/server/events/markdown_renderer_test.go @@ -2222,7 +2222,41 @@ Terraform will perform the following actions: ] } -Plan: 1 to add, 1 to change, 1 to destroy. +# aws_api_gateway_rest_api.rest_api will be updated in-place +~ resource "aws_api_gateway_rest_api" "rest_api" { + ~ body = <<-EOT + openapi: 3.0.0 + security: + - SomeAuth: [] + paths: + /someEndpoint: + get: + - operationId: someOperation + + operationId: someOperation2 + responses: + 204: + description: Empty response. + components: + schemas: + SomeEnum: + type: string + enum: + - value1 + - value2 + securitySchemes: + SomeAuth: + type: apiKey + in: header + name: Authorization + EOT + id = "4i5suz5c4l" + name = "test" + tags = {} + # (9 unchanged attributes hidden) + # (1 unchanged block hidden) + } + +Plan: 1 to add, 2 to change, 1 to destroy. ` cases := []struct { Description string @@ -2399,7 +2433,41 @@ Terraform will perform the following actions: ] } -Plan: 1 to add, 1 to change, 1 to destroy. +# aws_api_gateway_rest_api.rest_api will be updated in-place +! resource "aws_api_gateway_rest_api" "rest_api" { +! body = <<-EOT + openapi: 3.0.0 + security: + - SomeAuth: [] + paths: + /someEndpoint: + get: +- operationId: someOperation ++ operationId: someOperation2 + responses: + 204: + description: Empty response. + components: + schemas: + SomeEnum: + type: string + enum: + - value1 + - value2 + securitySchemes: + SomeAuth: + type: apiKey + in: header + name: Authorization + EOT + id = "4i5suz5c4l" + name = "test" + tags = {} + # (9 unchanged attributes hidden) + # (1 unchanged block hidden) + } + +Plan: 1 to add, 2 to change, 1 to destroy. $$$ @@ -2407,7 +2475,7 @@ $$$ * :repeat: To **plan** this project again, comment: * $atlantis plan -d path -w workspace$ -Plan: 1 to add, 1 to change, 1 to destroy. +Plan: 1 to add, 2 to change, 1 to destroy. `, diff --git a/server/events/models/models.go b/server/events/models/models.go index 602c05035..5889d6a96 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -384,7 +384,7 @@ func (p *PlanSuccess) Summary() string { // DiffMarkdownFormattedTerraformOutput formats the Terraform output to match diff markdown format func (p PlanSuccess) DiffMarkdownFormattedTerraformOutput() string { - diffKeywordRegex := regexp.MustCompile(`(?m)^( +)([-+~]\s)(.*)(\s=\s|\s->\s|<<|\{|\(known after apply\)|\[)(.*)`) + diffKeywordRegex := regexp.MustCompile(`(?m)^( +)([-+~]\s)(.*)(\s=\s|\s->\s|<<|\{|\(known after apply\)| {2,}[^ ]+:.*)(.*)`) diffListRegex := regexp.MustCompile(`(?m)^( +)([-+~]\s)(".*",)`) diffTildeRegex := regexp.MustCompile(`(?m)^~`)