mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
As the cloud e2e tests evolved some common patters became apparent. This standardizes and consolidates the patterns into a common test runner that takes the table tests and runs them in parallel. Some tests also needed to be converted to utilize table tests.
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_backend_apply_before_init(t *testing.T) {
|
|
t.Parallel()
|
|
skipIfMissingEnvVar(t)
|
|
skipWithoutRemoteTerraformVersion(t)
|
|
|
|
cases := testCases{
|
|
"terraform apply with cloud block - blank state": {
|
|
operations: []operationSets{
|
|
{
|
|
prep: func(t *testing.T, orgName, dir string) {
|
|
wsName := "new-workspace"
|
|
tfBlock := terraformConfigCloudBackendName(orgName, wsName)
|
|
writeMainTF(t, tfBlock, dir)
|
|
},
|
|
commands: []tfCommand{
|
|
{
|
|
command: []string{"apply"},
|
|
expectedCmdOutput: `Terraform Cloud initialization required: please run "terraform init"`,
|
|
expectError: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"terraform apply with cloud block - local state": {
|
|
operations: []operationSets{
|
|
{
|
|
prep: func(t *testing.T, orgName, dir string) {
|
|
tfBlock := terraformConfigLocalBackend()
|
|
writeMainTF(t, tfBlock, dir)
|
|
},
|
|
commands: []tfCommand{
|
|
{
|
|
command: []string{"init"},
|
|
expectedCmdOutput: `Successfully configured the backend "local"!`,
|
|
},
|
|
{
|
|
command: []string{"apply", "-auto-approve"},
|
|
postInputOutput: []string{`Apply complete!`},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
prep: func(t *testing.T, orgName, dir string) {
|
|
wsName := "new-workspace"
|
|
tfBlock := terraformConfigCloudBackendName(orgName, wsName)
|
|
writeMainTF(t, tfBlock, dir)
|
|
},
|
|
commands: []tfCommand{
|
|
{
|
|
command: []string{"apply"},
|
|
expectedCmdOutput: `Terraform Cloud initialization required: please run "terraform init"`,
|
|
expectError: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
testRunner(t, cases, 1)
|
|
}
|