terraform: Updating tests for modules
This commit is contained in:
parent
bce9b664d8
commit
9a6c8490a0
|
@ -583,7 +583,7 @@ func TestContextApply(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContextApply_createBeforeDestroy(t *testing.T) {
|
||||
c := testConfig(t, "apply-good-create-before")
|
||||
m := testModule(t, "apply-good-create-before")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
|
@ -606,7 +606,7 @@ func TestContextApply_createBeforeDestroy(t *testing.T) {
|
|||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Config: c,
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
|
@ -933,7 +933,7 @@ func TestContextApply_provisionerFail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContextApply_provisionerFail_createBeforeDestroy(t *testing.T) {
|
||||
c := testConfig(t, "apply-provisioner-fail-create-before")
|
||||
m := testModule(t, "apply-provisioner-fail-create-before")
|
||||
p := testProvider("aws")
|
||||
pr := testProvisioner()
|
||||
p.ApplyFn = testApplyFn
|
||||
|
@ -961,7 +961,7 @@ func TestContextApply_provisionerFail_createBeforeDestroy(t *testing.T) {
|
|||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Config: c,
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
|
@ -988,7 +988,7 @@ func TestContextApply_provisionerFail_createBeforeDestroy(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
||||
c := testConfig(t, "apply-error-create-before")
|
||||
m := testModule(t, "apply-error-create-before")
|
||||
p := testProvider("aws")
|
||||
state := &State{
|
||||
Modules: []*ModuleState{
|
||||
|
@ -1009,7 +1009,7 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
|||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Config: c,
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
|
@ -1037,7 +1037,7 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContextApply_errorDestroy_createBeforeDestroy(t *testing.T) {
|
||||
c := testConfig(t, "apply-error-create-before")
|
||||
m := testModule(t, "apply-error-create-before")
|
||||
p := testProvider("aws")
|
||||
state := &State{
|
||||
Modules: []*ModuleState{
|
||||
|
@ -1058,7 +1058,7 @@ func TestContextApply_errorDestroy_createBeforeDestroy(t *testing.T) {
|
|||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Config: c,
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
|
|
|
@ -653,16 +653,21 @@ func TestGraphAddDiff_module(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGraphAddDiff_createBeforeDestroy(t *testing.T) {
|
||||
config := testConfig(t, "graph-diff-create-before")
|
||||
m := testModule(t, "graph-diff-create-before")
|
||||
diff := &Diff{
|
||||
Resources: map[string]*InstanceDiff{
|
||||
"aws_instance.bar": &InstanceDiff{
|
||||
Destroy: true,
|
||||
Attributes: map[string]*ResourceAttrDiff{
|
||||
"ami": &ResourceAttrDiff{
|
||||
Old: "abc",
|
||||
New: "xyz",
|
||||
RequiresNew: true,
|
||||
Modules: []*ModuleDiff{
|
||||
&ModuleDiff{
|
||||
Path: rootModulePath,
|
||||
Resources: map[string]*InstanceDiff{
|
||||
"aws_instance.bar": &InstanceDiff{
|
||||
Destroy: true,
|
||||
Attributes: map[string]*ResourceAttrDiff{
|
||||
"ami": &ResourceAttrDiff{
|
||||
Old: "abc",
|
||||
New: "xyz",
|
||||
RequiresNew: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -690,7 +695,7 @@ func TestGraphAddDiff_createBeforeDestroy(t *testing.T) {
|
|||
diffHash := checksumStruct(t, diff)
|
||||
|
||||
g, err := Graph(&GraphOpts{
|
||||
Config: config,
|
||||
Module: m,
|
||||
Diff: diff,
|
||||
State: state,
|
||||
})
|
||||
|
@ -722,33 +727,6 @@ func TestGraphAddDiff_createBeforeDestroy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGraphInitState(t *testing.T) {
|
||||
config := testConfig(t, "graph-basic")
|
||||
state := &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: rootModulePath,
|
||||
Resources: map[string]*InstanceDiff{
|
||||
"aws_instance.foo": &InstanceDiff{
|
||||
Destroy: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
g, err := Graph(&GraphOpts{Module: m, Diff: diff})
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(g.String())
|
||||
expected := strings.TrimSpace(testTerraformGraphDiffModuleStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad:\n\n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGraphAddDiff_moduleDestroy(t *testing.T) {
|
||||
m := testModule(t, "graph-diff-module")
|
||||
diff := &Diff{
|
||||
|
|
Loading…
Reference in New Issue