From 9b11ff03587053b70875e0d4944949ebfaeb6006 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 10 Feb 2021 13:47:42 -0500 Subject: [PATCH] remove outdated tests These cases are now caught early in the configuration loading process, and do not make it to the point of graph transformation. --- .../main.tf | 10 --- .../mod/main.tf | 2 - .../transform-provider-invalid/main.tf | 11 ---- .../transform-provider-invalid/mod/main.tf | 2 - terraform/transform_provider_test.go | 63 ------------------- 5 files changed, 88 deletions(-) delete mode 100644 terraform/testdata/transform-provider-implicit-module/main.tf delete mode 100644 terraform/testdata/transform-provider-implicit-module/mod/main.tf delete mode 100644 terraform/testdata/transform-provider-invalid/main.tf delete mode 100644 terraform/testdata/transform-provider-invalid/mod/main.tf diff --git a/terraform/testdata/transform-provider-implicit-module/main.tf b/terraform/testdata/transform-provider-implicit-module/main.tf deleted file mode 100644 index 141a04d3f..000000000 --- a/terraform/testdata/transform-provider-implicit-module/main.tf +++ /dev/null @@ -1,10 +0,0 @@ -provider "aws" { - alias = "foo" -} - -module "mod" { - source = "./mod" - providers = { - aws = aws.foo - } -} diff --git a/terraform/testdata/transform-provider-implicit-module/mod/main.tf b/terraform/testdata/transform-provider-implicit-module/mod/main.tf deleted file mode 100644 index 01cf0803c..000000000 --- a/terraform/testdata/transform-provider-implicit-module/mod/main.tf +++ /dev/null @@ -1,2 +0,0 @@ -resource "aws_instance" "bar" { -} diff --git a/terraform/testdata/transform-provider-invalid/main.tf b/terraform/testdata/transform-provider-invalid/main.tf deleted file mode 100644 index ec23232ae..000000000 --- a/terraform/testdata/transform-provider-invalid/main.tf +++ /dev/null @@ -1,11 +0,0 @@ -provider "aws" { -} - -module "mod" { - source = "./mod" - - # aws.foo doesn't exist, and should report an error - providers = { - aws = aws.foo - } -} diff --git a/terraform/testdata/transform-provider-invalid/mod/main.tf b/terraform/testdata/transform-provider-invalid/mod/main.tf deleted file mode 100644 index 03641197f..000000000 --- a/terraform/testdata/transform-provider-invalid/mod/main.tf +++ /dev/null @@ -1,2 +0,0 @@ -resource "aws_resource" "foo" { -} diff --git a/terraform/transform_provider_test.go b/terraform/transform_provider_test.go index 5b05c7a72..fbc9a4187 100644 --- a/terraform/transform_provider_test.go +++ b/terraform/transform_provider_test.go @@ -434,69 +434,6 @@ func TestProviderConfigTransformer_grandparentProviders(t *testing.T) { } } -// pass a specific provider into a module using it implicitly -func TestProviderConfigTransformer_implicitModule(t *testing.T) { - mod := testModule(t, "transform-provider-implicit-module") - concrete := func(a *NodeAbstractProvider) dag.Vertex { return a } - - g := Graph{Path: addrs.RootModuleInstance} - { - tf := &ConfigTransformer{Config: mod} - if err := tf.Transform(&g); err != nil { - t.Fatalf("err: %s", err) - } - } - { - tf := &AttachResourceConfigTransformer{Config: mod} - if err := tf.Transform(&g); err != nil { - t.Fatalf("err: %s", err) - } - } - { - tf := TransformProviders([]string{"aws"}, concrete, mod) - if err := tf.Transform(&g); err != nil { - t.Fatalf("err: %s", err) - } - } - - actual := strings.TrimSpace(g.String()) - expected := strings.TrimSpace(`module.mod.aws_instance.bar - provider["registry.terraform.io/hashicorp/aws"].foo -provider["registry.terraform.io/hashicorp/aws"].foo`) - if actual != expected { - t.Fatalf("wrong result\n\nexpected:\n%s\n\ngot:\n%s", expected, actual) - } -} - -// error out when a non-existent provider is named in a module providers map -func TestProviderConfigTransformer_invalidProvider(t *testing.T) { - mod := testModule(t, "transform-provider-invalid") - concrete := func(a *NodeAbstractProvider) dag.Vertex { return a } - - g := Graph{Path: addrs.RootModuleInstance} - { - tf := &ConfigTransformer{Config: mod} - if err := tf.Transform(&g); err != nil { - t.Fatalf("err: %s", err) - } - } - { - tf := &AttachResourceConfigTransformer{Config: mod} - if err := tf.Transform(&g); err != nil { - t.Fatalf("err: %s", err) - } - } - - tf := TransformProviders([]string{"aws"}, concrete, mod) - err := tf.Transform(&g) - if err == nil { - t.Fatal("expected missing provider error") - } - if !strings.Contains(err.Error(), `provider["registry.terraform.io/hashicorp/aws"].foo`) { - t.Fatalf("error should reference missing provider, got: %s", err) - } -} - const testTransformProviderBasicStr = ` aws_instance.web provider["registry.terraform.io/hashicorp/aws"]