validate test updates

Remove a test that is no longer needed, since provider must be
explicitly defined for orphaned modules, and is covered in other context
tests.

Udpate a test fixture to better represent the origianl missing map
issue, since the ability to detect nil now made the old test invalid.
This commit is contained in:
James Bardin 2018-09-21 17:00:30 -04:00 committed by Martin Atkins
parent da20613deb
commit ebe3754fe6
3 changed files with 7 additions and 65 deletions

View File

@ -407,64 +407,6 @@ func TestContext2Validate_moduleDepsShouldNotCycle(t *testing.T) {
}
}
func TestContext2Validate_moduleProviderInheritOrphan(t *testing.T) {
m := testModule(t, "validate-module-pc-inherit-orphan")
p := testProvider("aws")
p.GetSchemaReturn = &ProviderSchema{
Provider: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"set": {Type: cty.String, Optional: true},
},
},
ResourceTypes: map[string]*configschema.Block{
"aws_instance": {
Attributes: map[string]*configschema.Attribute{},
},
},
}
c := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
Resources: map[string]*ResourceState{
"aws_instance.bar": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
},
},
},
},
},
}),
})
p.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
v, ok := c.Get("set")
if !ok {
return nil, []error{fmt.Errorf("not set")}
}
if v != "bar" {
return nil, []error{fmt.Errorf("bad: %#v", v)}
}
return nil, nil
}
diags := c.Validate()
if diags.HasErrors() {
t.Fatalf("unexpected error: %s", diags.Err())
}
}
func TestContext2Validate_moduleProviderVar(t *testing.T) {
m := testModule(t, "validate-module-pc-vars")
p := testProvider("aws")

View File

@ -2,7 +2,10 @@ module "mod" {
source = "./mod"
}
resource "template_instance" "root_template" {
compute_value = "ext: ${module.mod.base_config["base_template"]}"
compute = "value"
output "out" {
value = module.mod.base_config["base_template"]
}
resource "template_instance" "root_template" {
foo = module.mod.base_config["base_template"]
}

View File

@ -5,9 +5,6 @@ resource "template_instance" "example" {
output "base_config" {
value = {
base_template = "${template_instance.example.value}"
# without this we fail with no entries
extra = "value"
base_template = template_instance.example.value
}
}