Fix cloud e2e tests for updated migration flow
This commit is contained in:
parent
bac59d2480
commit
27aa51687e
|
@ -30,7 +30,7 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
|
|||
},
|
||||
{
|
||||
command: []string{"apply", "-auto-approve"},
|
||||
postInputOutput: []string{`Apply complete!`},
|
||||
expectedCmdOutput: `Apply complete!`,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -43,9 +43,11 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Should Terraform migrate your existing state?`,
|
||||
userInput: []string{"yes"},
|
||||
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
|
||||
expectedCmdOutput: `Migrating from backend "remote" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
command: []string{"workspace", "show"},
|
||||
|
@ -164,7 +166,11 @@ func Test_migrate_remote_backend_name_to_tfc_same_name(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
|
||||
expectedCmdOutput: `Migrating from backend "remote" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
command: []string{"workspace", "show"},
|
||||
|
@ -284,9 +290,11 @@ func Test_migrate_remote_backend_name_to_tfc_name_different_org(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Should Terraform migrate your existing state?`,
|
||||
userInput: []string{"yes"},
|
||||
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
|
||||
expectedCmdOutput: `Migrating from backend "remote" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
command: []string{"workspace", "show"},
|
||||
|
@ -415,10 +423,11 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
userInput: []string{"cloud-workspace", "yes"},
|
||||
expectedCmdOutput: `Migrating from backend "remote" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "cloud-workspace", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
|
@ -545,9 +554,10 @@ func Test_migrate_remote_backend_prefix_to_tfc_name_strategy_single_workspace(t
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Should Terraform migrate your existing state?`,
|
||||
userInput: []string{"yes"},
|
||||
expectedCmdOutput: `Migrating from backend "remote" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
|
@ -823,10 +833,11 @@ func Test_migrate_remote_backend_prefix_to_tfc_tags_strategy_single_workspace(t
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
userInput: []string{"cloud-workspace", "yes"},
|
||||
expectedCmdOutput: `Migrating from backend "remote" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "cloud-workspace", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -48,9 +48,11 @@ func Test_migrate_single_to_tfc(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init"},
|
||||
expectedCmdOutput: `Should Terraform migrate your existing state?`,
|
||||
userInput: []string{"yes"},
|
||||
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
|
||||
expectedCmdOutput: `Migrating from backend "local" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
command: []string{"workspace", "list"},
|
||||
|
@ -97,10 +99,11 @@ func Test_migrate_single_to_tfc(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init"},
|
||||
expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
userInput: []string{"new-workspace", "yes"},
|
||||
expectedCmdOutput: `Migrating from backend "local" to Terraform Cloud.`,
|
||||
userInput: []string{"yes", "new-workspace", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -70,8 +70,6 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Should Terraform migrate your existing state?`,
|
||||
userInput: []string{"yes"},
|
||||
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
|
@ -128,10 +126,10 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
userInput: []string{"new-workspace", "yes"},
|
||||
expectedCmdOutput: `There are no workspaces with the configured tags (app)`,
|
||||
userInput: []string{"new-workspace"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform can create a properly tagged workspace for you now.`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
{
|
||||
|
@ -197,9 +195,11 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init"},
|
||||
expectedCmdOutput: `Terraform Cloud requires all workspaces to be given an explicit name.`,
|
||||
expectError: true,
|
||||
userInput: []string{"new-workspace", "yes"},
|
||||
expectedCmdOutput: `There are no workspaces with the configured tags (app)`,
|
||||
userInput: []string{"new-workspace"},
|
||||
postInputOutput: []string{
|
||||
`Terraform can create a properly tagged workspace for you now.`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -341,9 +341,7 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
|
|||
expectedCmdOutput: `Switched to workspace "app-staging".`,
|
||||
},
|
||||
{
|
||||
command: []string{"apply"},
|
||||
expectedCmdOutput: `Do you want to perform these actions in workspace "app-staging"?`,
|
||||
userInput: []string{"yes"},
|
||||
command: []string{"apply", "-auto-approve"},
|
||||
postInputOutput: []string{`Apply complete!`},
|
||||
},
|
||||
{
|
||||
|
@ -368,20 +366,13 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Do you want to copy only your current workspace?`,
|
||||
userInput: []string{"yes", "yes"},
|
||||
postInputOutput: []string{
|
||||
`Should Terraform migrate your existing state?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
|
||||
postInputOutput: []string{`tag_val = "service"`},
|
||||
},
|
||||
{
|
||||
command: []string{"workspace", "show"},
|
||||
expectedCmdOutput: `service`, // this comes from the `prep` function
|
||||
},
|
||||
{
|
||||
command: []string{"output"},
|
||||
expectedCmdOutput: `tag_val = "app"`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -447,11 +438,9 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
|
|||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-ignore-remote-version"},
|
||||
expectedCmdOutput: `Would you like to rename your workspaces?`,
|
||||
userInput: []string{"1", "new-*", "1"},
|
||||
postInputOutput: []string{
|
||||
`How would you like to rename your workspaces?`,
|
||||
`Terraform Cloud has been successfully initialized!`},
|
||||
expectedCmdOutput: `There are no workspaces with the configured tags (billing)`,
|
||||
userInput: []string{"new-app-prod"},
|
||||
postInputOutput: []string{`Terraform Cloud has been successfully initialized!`},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -463,17 +452,13 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(wsList.Items) != 2 {
|
||||
if len(wsList.Items) != 1 {
|
||||
t.Logf("Expected the number of workspaces to be 2, but got %d", len(wsList.Items))
|
||||
}
|
||||
_, empty := getWorkspace(wsList.Items, "new-app-prod")
|
||||
if empty {
|
||||
t.Fatalf("expected workspaces to include 'new-app-prod' but didn't.")
|
||||
}
|
||||
_, empty = getWorkspace(wsList.Items, "new-app-staging")
|
||||
if empty {
|
||||
t.Fatalf("expected workspaces to include 'new-app-staging' but didn't.")
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue