command: Fix TestImport_remoteState
The import command was imposing the default state path at the CLI level, rather than leaving that to be handled by the backend. As a result, the output state was always forced to be terraform.tfstate, regardless of the backend settings.
This commit is contained in:
parent
2b9f92be31
commit
b316e4ab56
|
@ -39,7 +39,7 @@ func (c *ImportCommand) Run(args []string) int {
|
|||
|
||||
cmdFlags := c.Meta.flagSet("import")
|
||||
cmdFlags.IntVar(&c.Meta.parallelism, "parallelism", 0, "parallelism")
|
||||
cmdFlags.StringVar(&c.Meta.statePath, "state", DefaultStateFilename, "path")
|
||||
cmdFlags.StringVar(&c.Meta.statePath, "state", "", "path")
|
||||
cmdFlags.StringVar(&c.Meta.stateOutPath, "state-out", "", "path")
|
||||
cmdFlags.StringVar(&c.Meta.backupPath, "backup", "", "path")
|
||||
cmdFlags.StringVar(&configPath, "config", pwd, "path")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -161,7 +162,7 @@ func TestImport_remoteState(t *testing.T) {
|
|||
statePath := "imported.tfstate"
|
||||
|
||||
// init our backend
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
m := Meta{
|
||||
testingOverrides: metaOverridesForProvider(testProvider()),
|
||||
Ui: ui,
|
||||
|
@ -178,8 +179,10 @@ func TestImport_remoteState(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
// (Using log here rather than t.Log so that these messages interleave with other trace logs)
|
||||
log.Print("[TRACE] TestImport_remoteState running: terraform init")
|
||||
if code := ic.Run([]string{}); code != 0 {
|
||||
t.Fatalf("bad: \n%s", ui.ErrorWriter)
|
||||
t.Fatalf("init failed\n%s", ui.ErrorWriter)
|
||||
}
|
||||
|
||||
p := testProvider()
|
||||
|
@ -233,7 +236,7 @@ func TestImport_remoteState(t *testing.T) {
|
|||
"test_instance.foo",
|
||||
"bar",
|
||||
}
|
||||
|
||||
log.Printf("[TRACE] TestImport_remoteState running: terraform import %s %s", args[0], args[1])
|
||||
if code := c.Run(args); code != 0 {
|
||||
fmt.Println(ui.OutputWriter)
|
||||
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
||||
|
|
Loading…
Reference in New Issue