2021-09-22 23:53:33 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_migrate_tfc_to_other(t *testing.T) {
|
2021-11-19 22:03:38 +01:00
|
|
|
t.Parallel()
|
2021-11-12 18:00:24 +01:00
|
|
|
skipIfMissingEnvVar(t)
|
2021-11-19 22:03:38 +01:00
|
|
|
|
2021-12-16 21:23:42 +01:00
|
|
|
cases := testCases{
|
2021-09-22 23:53:33 +02:00
|
|
|
"migrate from cloud to local backend": {
|
|
|
|
operations: []operationSets{
|
|
|
|
{
|
|
|
|
prep: func(t *testing.T, orgName, dir string) {
|
|
|
|
wsName := "new-workspace"
|
|
|
|
tfBlock := terraformConfigCloudBackendName(orgName, wsName)
|
|
|
|
writeMainTF(t, tfBlock, dir)
|
|
|
|
},
|
|
|
|
commands: []tfCommand{
|
|
|
|
{
|
2021-10-09 14:47:12 +02:00
|
|
|
command: []string{"init"},
|
2021-10-19 23:06:41 +02:00
|
|
|
expectedCmdOutput: `Terraform Cloud has been successfully initialized!`,
|
2021-09-22 23:53:33 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
prep: func(t *testing.T, orgName, dir string) {
|
|
|
|
tfBlock := terraformConfigLocalBackend()
|
|
|
|
writeMainTF(t, tfBlock, dir)
|
|
|
|
},
|
|
|
|
commands: []tfCommand{
|
|
|
|
{
|
2021-11-13 02:07:10 +01:00
|
|
|
command: []string{"init"},
|
2021-10-09 14:47:12 +02:00
|
|
|
expectedCmdOutput: `Migrating state from Terraform Cloud to another backend is not yet implemented.`,
|
|
|
|
expectError: true,
|
2021-09-22 23:53:33 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-12-16 21:23:42 +01:00
|
|
|
testRunner(t, cases, 1)
|
2021-09-22 23:53:33 +02:00
|
|
|
}
|