terraform: some more test cases for sanity
This commit is contained in:
parent
82bf4f485b
commit
35352a2746
|
@ -1344,6 +1344,45 @@ func TestContextApply_provisionerCreateFail(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestContextApply_provisionerCreateFailNoId(t *testing.T) {
|
||||
m := testModule(t, "apply-provisioner-fail-create")
|
||||
p := testProvider("aws")
|
||||
pr := testProvisioner()
|
||||
p.DiffFn = testDiffFn
|
||||
|
||||
p.ApplyFn = func(
|
||||
info *InstanceInfo,
|
||||
is *InstanceState,
|
||||
id *InstanceDiff) (*InstanceState, error) {
|
||||
return nil, fmt.Errorf("error")
|
||||
}
|
||||
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(nil); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
state, err := ctx.Apply()
|
||||
if err == nil {
|
||||
t.Fatal("should error")
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(testTerraformApplyProvisionerFailCreateNoIdStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextApply_provisionerFail(t *testing.T) {
|
||||
m := testModule(t, "apply-provisioner-fail")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -281,6 +281,10 @@ aws_instance.bar: (1 tainted)
|
|||
Tainted ID 1 = foo
|
||||
`
|
||||
|
||||
const testTerraformApplyProvisionerFailCreateNoIdStr = `
|
||||
<no state>
|
||||
`
|
||||
|
||||
const testTerraformApplyProvisionerFailCreateBeforeDestroyStr = `
|
||||
aws_instance.bar: (1 tainted)
|
||||
ID = bar
|
||||
|
|
Loading…
Reference in New Issue