|
| 1 | +package execution |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/stretchr/testify/assert" |
| 5 | + "strings" |
| 6 | + "testing" |
| 7 | +) |
| 8 | + |
| 9 | +func TestCorrectCleanUpWithoutRegexDoesNotProduceException(t *testing.T) { |
| 10 | + stdout := ` |
| 11 | +Note: Objects have changed outside of Terraform |
| 12 | +
|
| 13 | +Terraform detected the following changes made outside of Terraform since the |
| 14 | +last "terraform apply" which may have affected this plan: |
| 15 | +
|
| 16 | + # docker_image.xxxx has been deleted |
| 17 | + - resource "docker_image" "aaa" { |
| 18 | +
|
| 19 | + } |
| 20 | +
|
| 21 | +
|
| 22 | +Unless you have made equivalent changes to your configuration, or ignored the |
| 23 | +relevant attributes using ignore_changes, the following plan may include |
| 24 | +actions to undo or respond to these changes. |
| 25 | +
|
| 26 | +───────────────────────────────────────────────────────────────────────────── |
| 27 | +
|
| 28 | +Terraform used the selected providers to generate the following execution |
| 29 | +plan. Resource actions are indicated with the following symbols: |
| 30 | + + create |
| 31 | +
|
| 32 | +Terraform will perform the following actions: |
| 33 | +
|
| 34 | + # docker_image.xxxx will be created |
| 35 | + + resource "docker_image" "xxx" { |
| 36 | + + id = (known after apply) |
| 37 | + + image_id = (known after apply) |
| 38 | + + name = "***.dkr.ecr.***.amazonaws.com/xxx-yyy:latest" |
| 39 | + + repo_digest = (known after apply) |
| 40 | + + triggers = { |
| 41 | + + "dir_sha1" = "aaaa" |
| 42 | + } |
| 43 | +
|
| 44 | + + build { |
| 45 | + + cache_from = [] |
| 46 | + + context = "docker/" |
| 47 | + + dockerfile = "Dockerfile" |
| 48 | + + extra_hosts = [] |
| 49 | + + remove = true |
| 50 | + + security_opt = [] |
| 51 | + + tag = [ |
| 52 | + + "xxx:latest", |
| 53 | + ] |
| 54 | + } |
| 55 | + } |
| 56 | +
|
| 57 | + # docker_registry_image.xxx will be created |
| 58 | + + resource "docker_registry_image" "xxx" { |
| 59 | + + id = (known after apply) |
| 60 | + + insecure_skip_verify = false |
| 61 | + + keep_remotely = true |
| 62 | + + name = "***.dkr.ecr.***.amazonaws.com/xxx-yyy:latest" |
| 63 | + + sha256_digest = (known after apply) |
| 64 | + } |
| 65 | +
|
| 66 | +Plan: 2 to add, 0 to change, 0 to destroy. |
| 67 | +` |
| 68 | + res := cleanupTerraformPlan(true, nil, stdout, "") |
| 69 | + index := strings.Index(stdout, "Terraform will perform the following actions:") |
| 70 | + assert.Equal(t, stdout[index:], res) |
| 71 | +} |
0 commit comments