Merge pull request #29621 from hashicorp/error-on-unused-test-answers
command: Ensure all answers were used in command.testInputResponseMap
This commit is contained in:
commit
08a86b6c13
|
@ -716,6 +716,10 @@ func testInputMap(t *testing.T, answers map[string]string) func() {
|
||||||
|
|
||||||
// Return the cleanup
|
// Return the cleanup
|
||||||
return func() {
|
return func() {
|
||||||
|
if len(testInputResponseMap) > 0 {
|
||||||
|
t.Fatalf("expected no unused answers provided to command.testInputMap, got: %v", testInputResponseMap)
|
||||||
|
}
|
||||||
|
|
||||||
test = true
|
test = true
|
||||||
testInputResponseMap = nil
|
testInputResponseMap = nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,11 +540,6 @@ func TestInit_backendConfigFileChange(t *testing.T) {
|
||||||
defer os.RemoveAll(td)
|
defer os.RemoveAll(td)
|
||||||
defer testChdir(t, td)()
|
defer testChdir(t, td)()
|
||||||
|
|
||||||
// Ask input
|
|
||||||
defer testInputMap(t, map[string]string{
|
|
||||||
"backend-migrate-to-new": "no",
|
|
||||||
})()
|
|
||||||
|
|
||||||
ui := new(cli.MockUi)
|
ui := new(cli.MockUi)
|
||||||
view, _ := testView(t)
|
view, _ := testView(t)
|
||||||
c := &InitCommand{
|
c := &InitCommand{
|
||||||
|
|
|
@ -90,6 +90,7 @@ func (i *UIInput) Input(ctx context.Context, opts *terraform.InputOpts) (string,
|
||||||
return "", fmt.Errorf("unexpected input request in test: %s", opts.Id)
|
return "", fmt.Errorf("unexpected input request in test: %s", opts.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(testInputResponseMap, opts.Id)
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue