resintate disabled tests

Reinstate the disabled tests that required some sort of inheritance
during graph evaluation.
This commit is contained in:
James Bardin 2017-11-02 15:25:59 -04:00
parent 05ef30be2c
commit 241dae7ead
2 changed files with 130 additions and 134 deletions

View File

@ -2639,107 +2639,105 @@ module.child:
`) `)
} }
//// FIXME: how do we handle this one? func TestContext2Apply_moduleOrphanProvider(t *testing.T) {
//func TestContext2Apply_moduleOrphanProvider(t *testing.T) { m := testModule(t, "apply-module-orphan-provider-inherit")
// m := testModule(t, "apply-module-orphan-provider-inherit") p := testProvider("aws")
// p := testProvider("aws") p.ApplyFn = testApplyFn
// p.ApplyFn = testApplyFn p.DiffFn = testDiffFn
// p.DiffFn = testDiffFn
// p.ConfigureFn = func(c *ResourceConfig) error { p.ConfigureFn = func(c *ResourceConfig) error {
// if _, ok := c.Get("value"); !ok { if _, ok := c.Get("value"); !ok {
// return fmt.Errorf("value is not found") return fmt.Errorf("value is not found")
// } }
// return nil return nil
// } }
// // Create a state with an orphan module // Create a state with an orphan module
// state := &State{ state := &State{
// Modules: []*ModuleState{ Modules: []*ModuleState{
// &ModuleState{ &ModuleState{
// Path: []string{"root", "child"}, Path: []string{"root", "child"},
// Resources: map[string]*ResourceState{ Resources: map[string]*ResourceState{
// "aws_instance.bar": &ResourceState{ "aws_instance.bar": &ResourceState{
// Type: "aws_instance", Type: "aws_instance",
// Primary: &InstanceState{ Primary: &InstanceState{
// ID: "bar", ID: "bar",
// }, },
// }, },
// }, },
// }, },
// }, },
// } }
// ctx := testContext2(t, &ContextOpts{ ctx := testContext2(t, &ContextOpts{
// Module: m, Module: m,
// State: state, State: state,
// ProviderResolver: ResourceProviderResolverFixed( ProviderResolver: ResourceProviderResolverFixed(
// map[string]ResourceProviderFactory{ map[string]ResourceProviderFactory{
// "aws": testProviderFuncFixed(p), "aws": testProviderFuncFixed(p),
// }, },
// ), ),
// }) })
// if _, err := ctx.Plan(); err != nil { if _, err := ctx.Plan(); err != nil {
// t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
// } }
// if _, err := ctx.Apply(); err != nil { if _, err := ctx.Apply(); err != nil {
// t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
// } }
//} }
//// FIXME: how do we handle this one? func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) {
//func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) { m := testModule(t, "apply-module-orphan-provider-inherit")
// m := testModule(t, "apply-module-orphan-provider-inherit") p := testProvider("aws")
// p := testProvider("aws") p.ApplyFn = testApplyFn
// p.ApplyFn = testApplyFn p.DiffFn = testDiffFn
// p.DiffFn = testDiffFn
// p.ConfigureFn = func(c *ResourceConfig) error { p.ConfigureFn = func(c *ResourceConfig) error {
// if _, ok := c.Get("value"); !ok { if _, ok := c.Get("value"); !ok {
// return fmt.Errorf("value is not found") return fmt.Errorf("value is not found")
// } }
// return nil return nil
// } }
// // Create a state with an orphan module that is nested (grandchild) // Create a state with an orphan module that is nested (grandchild)
// state := &State{ state := &State{
// Modules: []*ModuleState{ Modules: []*ModuleState{
// &ModuleState{ &ModuleState{
// Path: []string{"root", "parent", "child"}, Path: []string{"root", "parent", "child"},
// Resources: map[string]*ResourceState{ Resources: map[string]*ResourceState{
// "aws_instance.bar": &ResourceState{ "aws_instance.bar": &ResourceState{
// Type: "aws_instance", Type: "aws_instance",
// Primary: &InstanceState{ Primary: &InstanceState{
// ID: "bar", ID: "bar",
// }, },
// }, },
// }, },
// }, },
// }, },
// } }
// ctx := testContext2(t, &ContextOpts{ ctx := testContext2(t, &ContextOpts{
// Module: m, Module: m,
// State: state, State: state,
// ProviderResolver: ResourceProviderResolverFixed( ProviderResolver: ResourceProviderResolverFixed(
// map[string]ResourceProviderFactory{ map[string]ResourceProviderFactory{
// "aws": testProviderFuncFixed(p), "aws": testProviderFuncFixed(p),
// }, },
// ), ),
// }) })
// if _, err := ctx.Plan(); err != nil { if _, err := ctx.Plan(); err != nil {
// t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
// } }
// if _, err := ctx.Apply(); err != nil { if _, err := ctx.Apply(); err != nil {
// t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
// } }
//} }
func TestContext2Apply_moduleGrandchildProvider(t *testing.T) { func TestContext2Apply_moduleGrandchildProvider(t *testing.T) {
m := testModule(t, "apply-module-grandchild-provider-inherit") m := testModule(t, "apply-module-grandchild-provider-inherit")

View File

@ -321,55 +321,53 @@ func TestContext2Validate_moduleDepsShouldNotCycle(t *testing.T) {
} }
} }
//// FIXME: provider must still exist in config, but we should be able to locate func TestContext2Validate_moduleProviderInheritOrphan(t *testing.T) {
//// it elsewhere m := testModule(t, "validate-module-pc-inherit-orphan")
//func TestContext2Validate_moduleProviderInheritOrphan(t *testing.T) { p := testProvider("aws")
// m := testModule(t, "validate-module-pc-inherit-orphan") c := testContext2(t, &ContextOpts{
// p := testProvider("aws") Module: m,
// c := testContext2(t, &ContextOpts{ ProviderResolver: ResourceProviderResolverFixed(
// Module: m, map[string]ResourceProviderFactory{
// ProviderResolver: ResourceProviderResolverFixed( "aws": testProviderFuncFixed(p),
// map[string]ResourceProviderFactory{ },
// "aws": testProviderFuncFixed(p), ),
// }, State: &State{
// ), Modules: []*ModuleState{
// State: &State{ &ModuleState{
// Modules: []*ModuleState{ Path: []string{"root", "child"},
// &ModuleState{ Resources: map[string]*ResourceState{
// Path: []string{"root", "child"}, "aws_instance.bar": &ResourceState{
// Resources: map[string]*ResourceState{ Type: "aws_instance",
// "aws_instance.bar": &ResourceState{ Primary: &InstanceState{
// Type: "aws_instance", ID: "bar",
// Primary: &InstanceState{ },
// ID: "bar", },
// }, },
// }, },
// }, },
// }, },
// }, })
// },
// })
// p.ValidateFn = func(c *ResourceConfig) ([]string, []error) { p.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
// v, ok := c.Get("set") v, ok := c.Get("set")
// if !ok { if !ok {
// return nil, []error{fmt.Errorf("not set")} return nil, []error{fmt.Errorf("not set")}
// } }
// if v != "bar" { if v != "bar" {
// return nil, []error{fmt.Errorf("bad: %#v", v)} return nil, []error{fmt.Errorf("bad: %#v", v)}
// } }
// return nil, nil return nil, nil
// } }
// w, e := c.Validate() w, e := c.Validate()
// if len(w) > 0 { if len(w) > 0 {
// t.Fatalf("bad: %#v", w) t.Fatalf("bad: %#v", w)
// } }
// if len(e) > 0 { if len(e) > 0 {
// t.Fatalf("bad: %s", e) t.Fatalf("bad: %s", e)
// } }
//} }
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")