Cloud UX test fixes

This commit is contained in:
Omar Ismail 2021-10-19 17:06:41 -04:00 committed by Chris Arcand
parent 09d5b70b7a
commit 86f93a2cbc
7 changed files with 41 additions and 41 deletions

View File

@ -18,7 +18,7 @@ import (
func Test_terraform_apply_autoApprove(t *testing.T) { func Test_terraform_apply_autoApprove(t *testing.T) {
ctx := context.Background() ctx := context.Background()
tfVersion := "1.1.0-tfc-integration" tfVersion := "1.1.0-tfc-integration"
if !hasTerraformVersion(version) { if !hasTerraformVersion(t, tfVersion) {
t.Skip("Skipping test because TFC does not have current terraform version.") t.Skip("Skipping test because TFC does not have current terraform version.")
} }
@ -42,7 +42,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"apply"}, command: []string{"apply"},
@ -82,7 +82,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"apply"}, command: []string{"apply"},
@ -122,7 +122,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"apply", "-auto-approve"}, command: []string{"apply", "-auto-approve"},
@ -160,7 +160,7 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"apply", "-auto-approve"}, command: []string{"apply", "-auto-approve"},

View File

@ -197,7 +197,7 @@ func writeMainTF(t *testing.T, block string, dir string) {
} }
// Ensure that TFC/E has a particular terraform version. // Ensure that TFC/E has a particular terraform version.
func hasTerraformVersion(version string) bool { func hasTerraformVersion(t *testing.T, version string) bool {
opts := tfe.AdminTerraformVersionsListOptions{ opts := tfe.AdminTerraformVersionsListOptions{
ListOptions: tfe.ListOptions{ ListOptions: tfe.ListOptions{
PageNumber: 1, PageNumber: 1,

View File

@ -68,7 +68,7 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
userInput: []string{"yes", "yes"}, userInput: []string{"yes", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to Terraform Cloud?`, `Do you want to copy existing state to Terraform Cloud?`,
`Successfully configured Terraform Cloud!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -309,7 +309,7 @@ func Test_migrate_multi_to_tfc_cloud_tags_strategy(t *testing.T) {
`Would you like to rename your workspaces?`, `Would you like to rename your workspaces?`,
"What pattern would you like to add to all your workspaces?", "What pattern would you like to add to all your workspaces?",
"The currently selected workspace (prod) does not exist.", "The currently selected workspace (prod) does not exist.",
"Terraform has been successfully initialized!"}, "Terraform Cloud has been successfully initialized!"},
}, },
{ {
command: []string{"workspace", "select", "app-prod"}, command: []string{"workspace", "select", "app-prod"},

View File

@ -50,9 +50,9 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `Do you want to copy existing state to the new backend?`, expectedCmdOutput: `Do you want to copy existing state to Terraform Cloud?`,
userInput: []string{"yes"}, userInput: []string{"yes"},
postInputOutput: []string{`Successfully configured Terraform Cloud!`}, postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -102,7 +102,7 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `Terraform has been successfully initialized!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -232,9 +232,9 @@ func Test_migrate_remote_backend_name_to_tfc_name_different_org(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `Do you want to copy existing state to the new backend?`, expectedCmdOutput: `Do you want to copy existing state to Terraform Cloud?`,
userInput: []string{"yes"}, userInput: []string{"yes"},
postInputOutput: []string{`Successfully configured Terraform Cloud!`}, postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -376,8 +376,8 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) {
expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`, expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`,
userInput: []string{"cloud-workspace", "yes"}, userInput: []string{"cloud-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to the new backend?`, `Do you want to copy existing state to Terraform Cloud?`,
`Successfully configured the backend "cloud"!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -513,10 +513,10 @@ func Test_migrate_remote_backend_prefix_to_tfc_name(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `Do you want to copy existing state to the new backend?`, expectedCmdOutput: `Do you want to copy existing state to Terraform Cloud?`,
userInput: []string{"yes"}, userInput: []string{"yes"},
postInputOutput: []string{ postInputOutput: []string{
`Successfully configured Terraform Cloud!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -581,7 +581,7 @@ func Test_migrate_remote_backend_prefix_to_tfc_name(t *testing.T) {
expectedCmdOutput: `Do you want to copy only your current workspace?`, expectedCmdOutput: `Do you want to copy only your current workspace?`,
userInput: []string{"yes"}, userInput: []string{"yes"},
postInputOutput: []string{ postInputOutput: []string{
`Successfully configured the backend "cloud"!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -731,11 +731,11 @@ func Test_migrate_remote_backend_prefix_to_tfc_tags(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `The "cloud" backend configuration only allows named workspaces!`, expectedCmdOutput: `The Terraform Cloud configuration only allows named workspaces!`,
userInput: []string{"cloud-workspace", "yes"}, userInput: []string{"cloud-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to the new backend?`, `Do you want to copy existing state to Terraform Cloud?`,
`Successfully configured the backend "cloud"!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "list"}, command: []string{"workspace", "list"},
@ -801,7 +801,7 @@ func Test_migrate_remote_backend_prefix_to_tfc_tags(t *testing.T) {
expectedCmdOutput: `Would you like to rename your workspaces?`, expectedCmdOutput: `Would you like to rename your workspaces?`,
userInput: []string{"1", "*"}, userInput: []string{"1", "*"},
postInputOutput: []string{`What pattern would you like to add to all your workspaces?`, postInputOutput: []string{`What pattern would you like to add to all your workspaces?`,
`Successfully configured the backend "cloud"!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},

View File

@ -50,9 +50,9 @@ func Test_migrate_single_to_tfc(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state"}, command: []string{"init", "-migrate-state"},
expectedCmdOutput: `Do you want to copy existing state to the Terraform Cloud?`, expectedCmdOutput: `Do you want to copy existing state to Terraform Cloud?`,
userInput: []string{"yes"}, userInput: []string{"yes"},
postInputOutput: []string{`Successfully configured Terraform Cloud!`}, postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "list"}, command: []string{"workspace", "list"},
@ -104,8 +104,8 @@ func Test_migrate_single_to_tfc(t *testing.T) {
expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`, expectedCmdOutput: `Terraform Cloud configuration only allows named workspaces!`,
userInput: []string{"new-workspace", "yes"}, userInput: []string{"new-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to the new backend?`, `Do you want to copy existing state to Terraform Cloud?`,
`Successfully configured Terraform Cloud!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "list"}, command: []string{"workspace", "list"},

View File

@ -28,7 +28,7 @@ func Test_migrate_tfc_to_other(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
}, },
}, },

View File

@ -17,7 +17,7 @@ import (
func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) { func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
ctx := context.Background() ctx := context.Background()
tfVersion := "1.1.0-tfc-integration" tfVersion := "1.1.0-tfc-integration"
if !hasTerraformVersion(version) { if !hasTerraformVersion(t, tfVersion) {
t.Skip("Skipping test because TFC does not have current terraform version.") t.Skip("Skipping test because TFC does not have current terraform version.")
} }
@ -49,7 +49,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -76,9 +76,9 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `Do you want to copy existing state to the new backend?`, expectedCmdOutput: `Do you want to copy existing state to Terraform Cloud?`,
userInput: []string{"yes"}, userInput: []string{"yes"},
postInputOutput: []string{`Successfully configured the backend "cloud"!`}, postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -117,7 +117,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `Successfully configured the backend "cloud"!`, expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
}, },
{ {
command: []string{"apply"}, command: []string{"apply"},
@ -136,11 +136,11 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
commands: []tfCommand{ commands: []tfCommand{
{ {
command: []string{"init", "-migrate-state", "-ignore-remote-version"}, command: []string{"init", "-migrate-state", "-ignore-remote-version"},
expectedCmdOutput: `The "cloud" backend configuration only allows named workspaces!`, expectedCmdOutput: `The Terraform Cloud configuration only allows named workspaces!`,
userInput: []string{"new-workspace", "yes"}, userInput: []string{"new-workspace", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to the new backend?`, `Do you want to copy existing state to Terraform Cloud?`,
`Successfully configured the backend "cloud"!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -240,7 +240,7 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) { func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
ctx := context.Background() ctx := context.Background()
tfVersion := "1.1.0-tfc-integration" tfVersion := "1.1.0-tfc-integration"
if !hasTerraformVersion(version) { if !hasTerraformVersion(t, tfVersion) {
t.Skip("Skipping test because TFC does not have current terraform version.") t.Skip("Skipping test because TFC does not have current terraform version.")
} }
@ -276,7 +276,7 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `The currently selected workspace (default) does not exist.`, expectedCmdOutput: `The currently selected workspace (default) does not exist.`,
userInput: []string{"1"}, userInput: []string{"1"},
postInputOutput: []string{`Terraform has been successfully initialized!`}, postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"apply"}, command: []string{"apply"},
@ -319,8 +319,8 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
expectedCmdOutput: `Do you want to copy only your current workspace?`, expectedCmdOutput: `Do you want to copy only your current workspace?`,
userInput: []string{"yes", "yes"}, userInput: []string{"yes", "yes"},
postInputOutput: []string{ postInputOutput: []string{
`Do you want to copy existing state to the new backend?`, `Do you want to copy existing state to Terraform Cloud?`,
`Terraform has been successfully initialized!`}, `Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"workspace", "show"}, command: []string{"workspace", "show"},
@ -370,7 +370,7 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
command: []string{"init"}, command: []string{"init"},
expectedCmdOutput: `The currently selected workspace (default) does not exist.`, expectedCmdOutput: `The currently selected workspace (default) does not exist.`,
userInput: []string{"1"}, userInput: []string{"1"},
postInputOutput: []string{`Terraform has been successfully initialized!`}, postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
}, },
{ {
command: []string{"apply", "-auto-approve"}, command: []string{"apply", "-auto-approve"},
@ -401,7 +401,7 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
postInputOutput: []string{ postInputOutput: []string{
`What pattern would you like to add to all your workspaces?`, `What pattern would you like to add to all your workspaces?`,
`The currently selected workspace (app-staging) does not exist.`, `The currently selected workspace (app-staging) does not exist.`,
`Successfully configured the backend "cloud"!`}, `Terraform Cloud has been successfully initialized!`},
}, },
}, },
}, },