Skip to content

Commit 4c2528d

Browse files
committed
Remove test that requires test to supply input for user prompt
This test passes when run in isolation but fails when run alongside other tests, even when skipping all other tests using `testStdinPipe`. I don't think the value of this test is great enough to start changing how we test stdin input.
1 parent 39df4e1 commit 4c2528d

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

internal/command/init_test.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) {
34353435
})
34363436

34373437
// Tests outcome when input enabled and disabled
3438-
t.Run("if the default workspace is selected and doesn't exist, but other custom workspaces do exist...", func(t *testing.T) {
3438+
t.Run("if the default workspace is selected and doesn't exist, but other custom workspaces do exist and input is disabled, an error is returned", func(t *testing.T) {
34393439
// Create a temporary, uninitialized working directory with configuration including a state store
34403440
td := t.TempDir()
34413441
testCopyDir(t, testFixturePath("init-with-state-store"), td)
@@ -3498,32 +3498,6 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) {
34983498

34993499
t.Fatalf("unexpected error: %s", err)
35003500
}
3501-
3502-
// If input is enabled, users are prompted to select an existing workspace via input.
3503-
// This allows the init command to complete successfully.
3504-
args = []string{"-enable-pluggable-state-storage-experiment=true"}
3505-
defer testStdinPipe(t, strings.NewReader("1\n"))() // supply input to prompt
3506-
3507-
ui = new(cli.MockUi)
3508-
view, done = testView(t)
3509-
c.Meta.Ui = ui
3510-
c.Meta.View = view
3511-
code = c.Run(args)
3512-
testOutput = done(t)
3513-
if code != 0 {
3514-
t.Fatalf("expected code 0 exit code, got %d, output: \n%s", code, testOutput.All())
3515-
}
3516-
output = testOutput.All()
3517-
expectedOutput = "Terraform has been successfully initialized!"
3518-
if !strings.Contains(cleanString(output), expectedOutput) {
3519-
t.Fatalf("expected output to include %q, but got':\n %s", expectedOutput, cleanString(output))
3520-
}
3521-
// Backend state file is made here, as init completes with a different workspace in use.
3522-
statePath = filepath.Join(meta.DataDir(), DefaultStateFilename)
3523-
_, err = os.Stat(statePath)
3524-
if pathErr, ok := err.(*os.PathError); ok && os.IsNotExist(pathErr.Err) {
3525-
t.Fatalf("expected backend state file to created, but it doesn't")
3526-
}
35273501
})
35283502

35293503
// TODO(SarahFrench/radeksimko): Add test cases below:

0 commit comments

Comments
 (0)