command: TestInit_fromModule_explicitDest guard against other tests

Some other test is leaving behind a terraform.tfstate after it concludes,
which can cause this test to fail in a strange way due to picking up
extra provider requirements from that state.

This check doesn't fix that problem, but it at least makes the test fail
in a more helpful way to avoid time wasted trying to debug this test when
it's some other test that actually has the bug.
This commit is contained in:
Martin Atkins 2018-11-09 15:18:00 -08:00
parent ced06a4ca3
commit 8c54da0ad2
1 changed files with 8 additions and 0 deletions

View File

@ -79,6 +79,14 @@ func TestInit_fromModule_explicitDest(t *testing.T) {
},
}
if _, err := os.Stat(DefaultStateFilename); err == nil {
// This should never happen; it indicates a bug in another test
// is causing a terraform.tfstate to get left behind in our directory
// here, which can interfere with our init process in a way that
// isn't relevant to this test.
t.Fatalf("some other test has left terraform.tfstate behind")
}
args := []string{
"-from-module=" + testFixturePath("init"),
dir,