From 53b5b95ef553947605cee81d8e023e49e144946a Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 16 Nov 2018 16:37:02 -0800 Subject: [PATCH] command: Fix TestRefresh_backup The local filesystem state manager no longer creates backup files eagerly, instead creating them only if on first write there is already a snapshot present in the target file. Therefore for this test to exercise the codepaths it intends to we must create an initial state snapshot for it to overwrite, creating the backup in the process. There are several other tests for this behavior elsewhere, so this test is primarily to verify that the refresh command is configuring the backend appropriately to get the backups written in the desired location. --- command/refresh_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/command/refresh_test.go b/command/refresh_test.go index 843cd213d..928384c37 100644 --- a/command/refresh_test.go +++ b/command/refresh_test.go @@ -511,8 +511,14 @@ func TestRefresh_backup(t *testing.T) { t.Fatalf("err: %s", err) } outPath := outf.Name() - outf.Close() - os.Remove(outPath) + defer outf.Close() + + // Need to put some state content in the output file so that there's + // something to back up. + err = statefile.Write(statefile.New(state, "baz", 0), outf) + if err != nil { + t.Fatalf("error writing initial output state file %s", err) + } // Backup path backupf, err := ioutil.TempFile(testingDir, "tf")