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:
parent
da20613deb
commit
ebe3754fe6
|
@ -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) {
|
func TestContext2Validate_moduleProviderVar(t *testing.T) {
|
||||||
m := testModule(t, "validate-module-pc-vars")
|
m := testModule(t, "validate-module-pc-vars")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
|
|
@ -2,7 +2,10 @@ module "mod" {
|
||||||
source = "./mod"
|
source = "./mod"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "template_instance" "root_template" {
|
output "out" {
|
||||||
compute_value = "ext: ${module.mod.base_config["base_template"]}"
|
value = module.mod.base_config["base_template"]
|
||||||
compute = "value"
|
}
|
||||||
|
|
||||||
|
resource "template_instance" "root_template" {
|
||||||
|
foo = module.mod.base_config["base_template"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,6 @@ resource "template_instance" "example" {
|
||||||
|
|
||||||
output "base_config" {
|
output "base_config" {
|
||||||
value = {
|
value = {
|
||||||
base_template = "${template_instance.example.value}"
|
base_template = template_instance.example.value
|
||||||
|
|
||||||
# without this we fail with no entries
|
|
||||||
extra = "value"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue