Skip to content

Commit

Permalink
command/init: add test for -backend-config k/v
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Mar 17, 2017
1 parent f237fe2 commit c87f3df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions command/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,33 @@ func TestInit_backendConfigFileChange(t *testing.T) {
}
}

func TestInit_backendConfigKV(t *testing.T) {
// Create a temporary working directory that is empty
td := tempDir(t)
copy.CopyDir(testFixturePath("init-backend-config-kv"), td)
defer os.RemoveAll(td)
defer testChdir(t, td)()

ui := new(cli.MockUi)
c := &InitCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}

args := []string{"-backend-config", "path=hello"}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}

// Read our saved backend config and verify we have our settings
state := testStateRead(t, filepath.Join(DefaultDataDir, DefaultStateFilename))
if v := state.Backend.Config["path"]; v != "hello" {
t.Fatalf("bad: %#v", v)
}
}

func TestInit_copyBackendDst(t *testing.T) {
// Create a temporary working directory that is empty
td := tempDir(t)
Expand Down
3 changes: 3 additions & 0 deletions command/test-fixtures/init-backend-config-kv/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
backend "local" {}
}

0 comments on commit c87f3df

Please sign in to comment.