From 8c54da0ad26c7e6dc52c2aa122cac52ade9581b7 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 9 Nov 2018 15:18:00 -0800 Subject: [PATCH] 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. --- command/init_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/command/init_test.go b/command/init_test.go index d50baebd6..ade5c533c 100644 --- a/command/init_test.go +++ b/command/init_test.go @@ -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,