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) {
// m := testModule(t, "apply-module-orphan-provider-inherit")
// p := testProvider("aws")
// p.ApplyFn = testApplyFn
// p.DiffFn = testDiffFn
func TestContext2Apply_moduleOrphanProvider(t *testing.T) {
m := testModule(t, "apply-module-orphan-provider-inherit")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
// p.ConfigureFn = func(c *ResourceConfig) error {
// if _, ok := c.Get("value"); !ok {
// return fmt.Errorf("value is not found")
// }
p.ConfigureFn = func(c *ResourceConfig) error {
if _, ok := c.Get("value"); !ok {
return fmt.Errorf("value is not found")
}
// return nil
// }
return nil
}
// // Create a state with an orphan module
// state := &State{
// Modules: []*ModuleState{
// &ModuleState{
// Path: []string{"root", "child"},
// Resources: map[string]*ResourceState{
// "aws_instance.bar": &ResourceState{
// Type: "aws_instance",
// Primary: &InstanceState{
// ID: "bar",
// },
// },
// },
// },
// },
// }
// Create a state with an orphan module
state := &State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
Resources: map[string]*ResourceState{
"aws_instance.bar": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
},
},
},
},
},
}
// ctx := testContext2(t, &ContextOpts{
// Module: m,
// State: state,
// ProviderResolver: ResourceProviderResolverFixed(
// map[string]ResourceProviderFactory{
// "aws": testProviderFuncFixed(p),
// },
// ),
// })
ctx := testContext2(t, &ContextOpts{
Module: m,
State: state,
ProviderResolver: ResourceProviderResolverFixed(
map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
),
})
// if _, err := ctx.Plan(); err != nil {
// t.Fatalf("err: %s", err)
// }
if _, err := ctx.Plan(); err != nil {
t.Fatalf("err: %s", err)
}
// if _, err := ctx.Apply(); err != nil {
// t.Fatalf("err: %s", err)
// }
//}
if _, err := ctx.Apply(); err != nil {
t.Fatalf("err: %s", err)
}
}
//// FIXME: how do we handle this one?
//func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) {
// m := testModule(t, "apply-module-orphan-provider-inherit")
// p := testProvider("aws")
// p.ApplyFn = testApplyFn
// p.DiffFn = testDiffFn
func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) {
m := testModule(t, "apply-module-orphan-provider-inherit")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
// p.ConfigureFn = func(c *ResourceConfig) error {
// if _, ok := c.Get("value"); !ok {
// return fmt.Errorf("value is not found")
// }
p.ConfigureFn = func(c *ResourceConfig) error {
if _, ok := c.Get("value"); !ok {
return fmt.Errorf("value is not found")
}
// return nil
// }
return nil
}
// // Create a state with an orphan module that is nested (grandchild)
// state := &State{
// Modules: []*ModuleState{
// &ModuleState{
// Path: []string{"root", "parent", "child"},
// Resources: map[string]*ResourceState{
// "aws_instance.bar": &ResourceState{
// Type: "aws_instance",
// Primary: &InstanceState{
// ID: "bar",
// },
// },
// },
// },
// },
// }
// Create a state with an orphan module that is nested (grandchild)
state := &State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "parent", "child"},
Resources: map[string]*ResourceState{
"aws_instance.bar": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
},
},
},
},
},
}
// ctx := testContext2(t, &ContextOpts{
// Module: m,
// State: state,
// ProviderResolver: ResourceProviderResolverFixed(
// map[string]ResourceProviderFactory{
// "aws": testProviderFuncFixed(p),
// },
// ),
// })
ctx := testContext2(t, &ContextOpts{
Module: m,
State: state,
ProviderResolver: ResourceProviderResolverFixed(
map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
),
})
// if _, err := ctx.Plan(); err != nil {
// t.Fatalf("err: %s", err)
// }
if _, err := ctx.Plan(); err != nil {
t.Fatalf("err: %s", err)
}
// if _, err := ctx.Apply(); err != nil {
// t.Fatalf("err: %s", err)
// }
//}
if _, err := ctx.Apply(); err != nil {
t.Fatalf("err: %s", err)
}
}
func TestContext2Apply_moduleGrandchildProvider(t *testing.T) {
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
//// it elsewhere
//func TestContext2Validate_moduleProviderInheritOrphan(t *testing.T) {
// m := testModule(t, "validate-module-pc-inherit-orphan")
// p := testProvider("aws")
// c := testContext2(t, &ContextOpts{
// Module: m,
// ProviderResolver: ResourceProviderResolverFixed(
// map[string]ResourceProviderFactory{
// "aws": testProviderFuncFixed(p),
// },
// ),
// State: &State{
// Modules: []*ModuleState{
// &ModuleState{
// Path: []string{"root", "child"},
// Resources: map[string]*ResourceState{
// "aws_instance.bar": &ResourceState{
// Type: "aws_instance",
// Primary: &InstanceState{
// ID: "bar",
// },
// },
// },
// },
// },
// },
// })
func TestContext2Validate_moduleProviderInheritOrphan(t *testing.T) {
m := testModule(t, "validate-module-pc-inherit-orphan")
p := testProvider("aws")
c := testContext2(t, &ContextOpts{
Module: m,
ProviderResolver: ResourceProviderResolverFixed(
map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
),
State: &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)}
// }
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
// }
return nil, nil
}
// w, e := c.Validate()
// if len(w) > 0 {
// t.Fatalf("bad: %#v", w)
// }
// if len(e) > 0 {
// t.Fatalf("bad: %s", e)
// }
//}
w, e := c.Validate()
if len(w) > 0 {
t.Fatalf("bad: %#v", w)
}
if len(e) > 0 {
t.Fatalf("bad: %s", e)
}
}
func TestContext2Validate_moduleProviderVar(t *testing.T) {
m := testModule(t, "validate-module-pc-vars")