mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
terraform: walk static subgraphs
This commit is contained in:
parent
220c2be571
commit
cf5f26bd9a
@ -139,6 +139,27 @@ func TestContext2Validate_moduleGood(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContext2Validate_moduleBadResource(t *testing.T) {
|
||||||
|
m := testModule(t, "validate-module-bad-rc")
|
||||||
|
p := testProvider("aws")
|
||||||
|
c := testContext2(t, &ContextOpts{
|
||||||
|
Module: m,
|
||||||
|
Providers: map[string]ResourceProviderFactory{
|
||||||
|
"aws": testProviderFuncFixed(p),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
p.ValidateResourceReturnErrors = []error{fmt.Errorf("bad")}
|
||||||
|
|
||||||
|
w, e := c.Validate()
|
||||||
|
if len(w) > 0 {
|
||||||
|
t.Fatalf("bad: %#v", w)
|
||||||
|
}
|
||||||
|
if len(e) == 0 {
|
||||||
|
t.Fatalf("bad: %#v", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestContext2Validate_orphans(t *testing.T) {
|
func TestContext2Validate_orphans(t *testing.T) {
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
m := testModule(t, "validate-good")
|
m := testModule(t, "validate-good")
|
||||||
@ -480,27 +501,6 @@ func TestContext2Validate_varRefFilled(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func TestContextValidate_moduleBadResource(t *testing.T) {
|
|
||||||
m := testModule(t, "validate-module-bad-rc")
|
|
||||||
p := testProvider("aws")
|
|
||||||
c := testContext(t, &ContextOpts{
|
|
||||||
Module: m,
|
|
||||||
Providers: map[string]ResourceProviderFactory{
|
|
||||||
"aws": testProviderFuncFixed(p),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
p.ValidateResourceReturnErrors = []error{fmt.Errorf("bad")}
|
|
||||||
|
|
||||||
w, e := c.Validate()
|
|
||||||
if len(w) > 0 {
|
|
||||||
t.Fatalf("bad: %#v", w)
|
|
||||||
}
|
|
||||||
if len(e) == 0 {
|
|
||||||
t.Fatalf("bad: %#v", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContextValidate_moduleProviderInherit(t *testing.T) {
|
func TestContextValidate_moduleProviderInherit(t *testing.T) {
|
||||||
m := testModule(t, "validate-module-pc-inherit")
|
m := testModule(t, "validate-module-pc-inherit")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
@ -173,6 +173,17 @@ func (g *Graph) walk(walker GraphWalker) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the node has a subgraph, then walk the subgraph
|
||||||
|
if sn, ok := v.(GraphNodeSubgraph); ok {
|
||||||
|
log.Printf(
|
||||||
|
"[DEBUG] vertex %s: walking subgraph",
|
||||||
|
dag.VertexName(v))
|
||||||
|
|
||||||
|
if rerr = sn.Subgraph().walk(walker); rerr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user