mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
command: Fix TestInit_backendReinitConfigToExtra
This test was re-using the same InitCommand value to run multiple times, which is not realistic. Since we now cache configuration source code inside command.Meta on load, it's important that we use a fresh InitCommand instance here so it'll see the modified configuration file we've left on disk.
This commit is contained in:
parent
b5547f00f6
commit
297b3b8830
@ -509,11 +509,23 @@ func TestInit_backendReinitConfigToExtra(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// We need a fresh InitCommand here because the old one now has our configuration
|
||||
// file cached inside it, so it won't re-read the modification we just made.
|
||||
c = &InitCommand{
|
||||
Meta: Meta{
|
||||
testingOverrides: metaOverridesForProvider(testProvider()),
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
||||
args := []string{"-input=false", "-backend-config=path=foo"}
|
||||
if code := c.Run(args); code != 0 {
|
||||
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
||||
}
|
||||
state = testDataStateRead(t, filepath.Join(DefaultDataDir, DefaultStateFilename))
|
||||
if got, want := normalizeJSON(t, state.Backend.ConfigRaw), `{"path":"foo","workspace_dir":null}`; got != want {
|
||||
t.Errorf("wrong config after moving to arg\ngot: %s\nwant: %s", got, want)
|
||||
}
|
||||
|
||||
if state.Backend.Hash == backendHash {
|
||||
t.Fatal("state.Backend.Hash was not updated")
|
||||
|
Loading…
Reference in New Issue
Block a user