Skip to content

Commit

Permalink
added unit tests for breaking changes case
Browse files Browse the repository at this point in the history
  • Loading branch information
Devang Gaur committed Jan 15, 2021
1 parent b1c5360 commit ee97d5a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/iac-providers/terraform/v12/load-dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func TestLoadIacDir(t *testing.T) {
tfv12: TfV12{},
wantErr: commons.ErrLoadConfigDir,
},
{
name: "load invalid config dir",
dirPath: "./testdata/multiple-required-providers",
tfv12: TfV12{},
wantErr: commons.ErrLoadConfigDir,
},
}

for _, tt := range table {
Expand Down
6 changes: 6 additions & 0 deletions pkg/iac-providers/terraform/v12/load-file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func TestLoadIacFile(t *testing.T) {
tfv12: TfV12{},
wantErr: commons.ErrLoadConfigFile,
},
{
name: "destroy-provisioners",
filePath: "./testdata/destroy-provisioners/main.tf",
tfv12: TfV12{},
wantErr: commons.ErrLoadConfigFile,
},
}

for _, tt := range table {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
locals {
user = "name"
}

resource "null_resource" "a" {
connection {
host = self.hostname
user = local.user # ERROR: Invalid reference from destroy provisioner
}

provisioner "remote-exec" {
when = destroy
index = count.index
key = each.key

// path and terraform values are static, and do not create any
// dependencies.
dir = path.module
workspace = terraform.workspace
}
}

resource "null_resource" "b" {
connection {
host = self.hostname
# this is OK since there is no destroy provisioner
user = local.user
}

provisioner "remote-exec" {
}
}

resource "null_resource" "b" {
provisioner "remote-exec" {
when = destroy
connection {
host = self.hostname
user = local.user # ERROR: Invalid reference from destroy provisioner
}

command = "echo ${local.name}" # ERROR: Invalid reference from destroy provisioner
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform {
required_providers {
bar = {
version = "~>1.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform {
required_providers {
foo = {
version = "~>2.0.0"
}
}
}

0 comments on commit ee97d5a

Please sign in to comment.