terraform: minimal apply test case

This commit is contained in:
Armon Dadgar 2014-07-08 16:12:14 -07:00
parent 66c716540f
commit 8f4cd641df
3 changed files with 44 additions and 0 deletions

View File

@ -164,6 +164,36 @@ func TestContextApply(t *testing.T) {
}
}
func TestContextApply_Minimal(t *testing.T) {
c := testConfig(t, "apply-minimal")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext(t, &ContextOpts{
Config: c,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
if _, err := ctx.Plan(nil); err != nil {
t.Fatalf("err: %s", err)
}
ctx.variables = map[string]string{"value": "1"}
state, err := ctx.Apply()
if err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(state.String())
expected := strings.TrimSpace(testTerraformApplyMinimalStr)
if actual != expected {
t.Fatalf("bad: \n%s", actual)
}
}
func TestContextApply_cancel(t *testing.T) {
stopped := false

View File

@ -107,6 +107,15 @@ aws_instance.foo:
type = aws_instance
`
const testTerraformApplyMinimalStr = `
aws_instance.bar:
ID = foo
type = aws_instance
aws_instance.foo:
ID = foo
type = aws_instance
`
const testTerraformApplyDestroyStr = `
<no state>
`

View File

@ -0,0 +1,5 @@
resource "aws_instance" "foo" {
}
resource "aws_instance" "bar" {
}