Skip to content

Commit

Permalink
Use -auto-apply more liberally
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettclark committed Nov 4, 2021
1 parent 17b4554 commit 1010ea5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 74 deletions.
6 changes: 2 additions & 4 deletions internal/cloud/e2e/backend_apply_before_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ func Test_backend_apply_before_init(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "local"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down
36 changes: 12 additions & 24 deletions internal/cloud/e2e/migrate_state_multi_to_tfc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "local"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "new", "prod"},
expectedCmdOutput: `Created and switched to workspace "prod"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "select", "default"},
Expand Down Expand Up @@ -113,20 +109,16 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "local"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "new", "prod"},
expectedCmdOutput: `Created and switched to workspace "prod"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -268,20 +260,16 @@ func Test_migrate_multi_to_tfc_cloud_tags_strategy(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "local"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "new", "prod"},
expectedCmdOutput: `Created and switched to workspace "prod"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "select", "default"},
Expand Down
36 changes: 12 additions & 24 deletions internal/cloud/e2e/migrate_state_remote_backend_to_tfc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "remote"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "remote-workspace"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -89,10 +87,8 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "remote"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "remote-workspace"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -223,10 +219,8 @@ func Test_migrate_remote_backend_name_to_tfc_name_different_org(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "remote"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "remote-workspace"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -364,10 +358,8 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "remote"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "remote-workspace"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "show"},
Expand Down Expand Up @@ -512,10 +504,8 @@ func Test_migrate_remote_backend_prefix_to_tfc_name(t *testing.T) {
expectedCmdOutput: `Terraform has been successfully initialized!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "app-one"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -569,10 +559,8 @@ func Test_migrate_remote_backend_prefix_to_tfc_name(t *testing.T) {
postInputOutput: []string{`Terraform has been successfully initialized!`},
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "app-one"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
{
command: []string{"workspace", "list"},
Expand Down
12 changes: 4 additions & 8 deletions internal/cloud/e2e/migrate_state_single_to_tfc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ func Test_migrate_single_to_tfc(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "local"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -88,10 +86,8 @@ func Test_migrate_single_to_tfc(t *testing.T) {
expectedCmdOutput: `Successfully configured the backend "local"!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down
18 changes: 6 additions & 12 deletions internal/cloud/e2e/migrate_state_tfc_to_tfc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
expectedCmdOutput: `prod`, // this comes from the `prep` function
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "prod"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -119,10 +117,8 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "prod"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down Expand Up @@ -183,10 +179,8 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
},
{
command: []string{"apply"},
expectedCmdOutput: `Do you want to perform these actions in workspace "prod"?`,
userInput: []string{"yes"},
postInputOutput: []string{`Apply complete!`},
command: []string{"apply", "-auto-approve"},
postInputOutput: []string{`Apply complete!`},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/cloud/e2e/run_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func Test_cloud_run_variables(t *testing.T) {
if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil {
t.Fatal(err)
t.Fatalf(`Expected command output "%s", but got %v `, tfCmd.expectedCmdOutput, err)
}
}

Expand All @@ -132,7 +132,7 @@ func Test_cloud_run_variables(t *testing.T) {
output := tfCmd.postInputOutput[i]
_, err := exp.ExpectString(output)
if err != nil {
t.Fatal(err)
t.Fatalf(`Expected command output "%s", but got %v `, tfCmd.expectedCmdOutput, err)
}
}
}
Expand Down

0 comments on commit 1010ea5

Please sign in to comment.