command/init: add test for -backend-config k/v

This commit is contained in:
Mitchell Hashimoto 2017-03-17 10:22:48 -07:00
parent f237fe2752
commit c87f3dfdd5
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 30 additions and 0 deletions

View File

@ -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)

View File

@ -0,0 +1,3 @@
terraform {
backend "local" {}
}