backend/local: test fixes

for TestLocal_applyBackendFail, config is relative to the tests' wd
This commit is contained in:
Kristin Laemmert 2018-10-02 16:21:33 -07:00 committed by Martin Atkins
parent d865df7338
commit e84def1e29

View File

@ -181,12 +181,15 @@ test_instance.foo:
}
func TestLocal_applyBackendFail(t *testing.T) {
op, configCleanup := testOperationApply(t, "./test-fixtures/apply")
defer configCleanup()
b, cleanup := TestLocal(t)
defer cleanup()
p := TestLocalProvider(t, b, "test", applyFixtureSchema())
p.ApplyResourceChangeResponse = providers.ApplyResourceChangeResponse{NewState: cty.ObjectVal(map[string]cty.Value{
"id": cty.StringVal("yes"),
"ami": cty.StringVal("bar"),
})}
wd, err := os.Getwd()
if err != nil {
t.Fatalf("failed to get current working directory")
@ -197,11 +200,11 @@ func TestLocal_applyBackendFail(t *testing.T) {
}
defer os.Chdir(wd)
op, configCleanup := testOperationApply(t, wd+"/test-fixtures/apply")
defer configCleanup()
b.Backend = &backendWithFailingState{}
b.CLI = new(cli.MockUi)
p := TestLocalProvider(t, b, "test", applyFixtureSchema())
p.ApplyResourceChangeResponse = providers.ApplyResourceChangeResponse{NewState: cty.ObjectVal(map[string]cty.Value{"id": cty.StringVal("yes")})}
run, err := b.Operation(context.Background(), op)
if err != nil {
@ -223,6 +226,7 @@ func TestLocal_applyBackendFail(t *testing.T) {
test_instance.foo:
ID = yes
provider = provider.test
ami = bar
`)
}