failing test for backend re-init
This commit is contained in:
parent
c7c69a5e99
commit
cefc927e48
|
@ -1,6 +1,7 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -410,6 +411,51 @@ func TestInit_backendConfigKV(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestInit_backendConfigKVReInit(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{
|
||||
testingOverrides: metaOverridesForProvider(testProvider()),
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
||||
args := []string{"-backend-config", "path=test"}
|
||||
if code := c.Run(args); code != 0 {
|
||||
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
||||
}
|
||||
|
||||
ui = new(cli.MockUi)
|
||||
c = &InitCommand{
|
||||
Meta: Meta{
|
||||
testingOverrides: metaOverridesForProvider(testProvider()),
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
||||
// a second init should require no changes, nor should it change the backend.
|
||||
args = []string{"-input=false"}
|
||||
if code := c.Run(args); code != 0 {
|
||||
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
||||
}
|
||||
|
||||
// make sure the backend is configured how we expect
|
||||
configState := testDataStateRead(t, filepath.Join(DefaultDataDir, DefaultStateFilename))
|
||||
cfg := map[string]interface{}{}
|
||||
if err := json.Unmarshal(configState.Backend.ConfigRaw, &cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg["path"] != "test" {
|
||||
t.Fatalf(`expected backend path="test", got path="%v"`, cfg["path"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestInit_targetSubdir(t *testing.T) {
|
||||
// Create a temporary working directory that is empty
|
||||
td := tempDir(t)
|
||||
|
|
|
@ -823,6 +823,8 @@ func (m *Meta) backend_C_r_S_changed(c *configs.Backend, cHash int, sMgr *state.
|
|||
return nil, diags
|
||||
}
|
||||
|
||||
fmt.Println("HERE")
|
||||
|
||||
// Perform the migration
|
||||
err := m.backendMigrateState(&backendMigrateOpts{
|
||||
OneType: s.Backend.Type,
|
||||
|
|
|
@ -98,6 +98,7 @@ func (m *Meta) backendMigrateState(opts *backendMigrateOpts) error {
|
|||
// Multi-state to multi-state. We merge the states together (migrating
|
||||
// each from the source to the destination one by one).
|
||||
case !oneSingle && !twoSingle:
|
||||
fmt.Printf("STATES: %q\n", oneStates)
|
||||
// If the source only has one state and it is the default,
|
||||
// treat it as if it doesn't support multi-state.
|
||||
if len(oneStates) == 1 && oneStates[0] == backend.DefaultStateName {
|
||||
|
|
Loading…
Reference in New Issue