Update tests for new prompts

* Remove double question to migrate
* Remove parallelism (it has been flaky)
* Add subtests to apply_auto_approve_test (it was overlooked before)
This commit is contained in:
Barrett Clark 2021-11-17 16:00:47 -06:00 committed by Martin Atkins
parent 7d6d31eff8
commit 7aeaec9b48
6 changed files with 72 additions and 73 deletions

View File

@ -179,7 +179,10 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
},
},
}
for _, tc := range cases {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)
@ -237,7 +240,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
}
err = cmd.Wait()
if err != nil {
if err != nil && !tfCmd.expectError {
t.Fatal(err)
}
}
@ -246,5 +249,6 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
if tc.validations != nil {
tc.validations(t, organization.Name)
}
})
}
}

View File

@ -11,7 +11,7 @@ import (
func Test_backend_apply_before_init(t *testing.T) {
skipIfMissingEnvVar(t)
t.Parallel()
// t.Parallel()
skipWithoutRemoteTerraformVersion(t)
cases := map[string]struct {
@ -74,7 +74,7 @@ func Test_backend_apply_before_init(t *testing.T) {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)
@ -130,6 +130,7 @@ func Test_backend_apply_before_init(t *testing.T) {
}
}
}
err = cmd.Wait()
if err != nil && !tfCmd.expectError {
t.Fatal(err)

View File

@ -11,7 +11,7 @@ import (
func Test_init_with_empty_tags(t *testing.T) {
skipIfMissingEnvVar(t)
t.Parallel()
// t.Parallel()
skipWithoutRemoteTerraformVersion(t)
cases := map[string]struct {
@ -41,7 +41,7 @@ func Test_init_with_empty_tags(t *testing.T) {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)

View File

@ -62,10 +62,8 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
{
command: []string{"init"},
expectedCmdOutput: `Do you want to copy only your current workspace?`,
userInput: []string{"yes", "yes"},
postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`,
`Terraform Cloud has been successfully initialized!`},
userInput: []string{"yes"},
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
},
{
command: []string{"workspace", "show"},
@ -129,10 +127,8 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
{
command: []string{"init"},
expectedCmdOutput: `Do you want to copy only your current workspace?`,
userInput: []string{"yes", "yes"},
postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`,
`Terraform Cloud has been successfully initialized!`},
userInput: []string{"yes"},
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
},
{
command: []string{"workspace", "list"},
@ -197,10 +193,8 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
{
command: []string{"init"},
expectedCmdOutput: `Do you want to copy only your current workspace?`,
userInput: []string{"yes", "yes"},
postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`,
`Terraform Cloud has been successfully initialized!`},
userInput: []string{"yes"},
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
},
{
command: []string{"workspace", "select", "default"},
@ -233,7 +227,7 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)
@ -521,7 +515,7 @@ func Test_migrate_multi_to_tfc_cloud_tags_strategy(t *testing.T) {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)

View File

@ -131,7 +131,7 @@ func Test_migrate_single_to_tfc(t *testing.T) {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)

View File

@ -49,7 +49,7 @@ func Test_migrate_tfc_to_other(t *testing.T) {
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
// t.Parallel()
organization, cleanup := createOrganization(t)
defer cleanup()
exp, err := expect.NewConsole(defaultOpts()...)