terraform: minimal apply test case
This commit is contained in:
parent
66c716540f
commit
8f4cd641df
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
`
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
resource "aws_instance" "foo" {
|
||||
}
|
||||
|
||||
resource "aws_instance" "bar" {
|
||||
}
|
Loading…
Reference in New Issue