mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
command/init: add test for -backend-config k/v
This commit is contained in:
parent
f237fe2752
commit
c87f3dfdd5
@ -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 New Issue
Block a user