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.
This commit is contained in:
James Bardin 2021-02-10 13:47:42 -05:00
parent da252de1a0
commit 9b11ff0358
5 changed files with 0 additions and 88 deletions

View File

@ -1,10 +0,0 @@
provider "aws" {
alias = "foo"
}
module "mod" {
source = "./mod"
providers = {
aws = aws.foo
}
}

View File

@ -1,2 +0,0 @@
resource "aws_instance" "bar" {
}

View File

@ -1,11 +0,0 @@
provider "aws" {
}
module "mod" {
source = "./mod"
# aws.foo doesn't exist, and should report an error
providers = {
aws = aws.foo
}
}

View File

@ -1,2 +0,0 @@
resource "aws_resource" "foo" {
}

View File

@ -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 = ` const testTransformProviderBasicStr = `
aws_instance.web aws_instance.web
provider["registry.terraform.io/hashicorp/aws"] provider["registry.terraform.io/hashicorp/aws"]