mirror of
https://github.com/hashicorp/terraform.git
synced 2026-04-22 14:51:50 -04:00
command/init: add test for -backend-config k/v
This commit is contained in:
parent
f237fe2752
commit
c87f3dfdd5
2 changed files with 30 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
3
command/test-fixtures/init-backend-config-kv/main.tf
Normal file
3
command/test-fixtures/init-backend-config-kv/main.tf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
terraform {
|
||||
backend "local" {}
|
||||
}
|
||||
Loading…
Reference in a new issue