mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
remove build tags for cloud e2e
This commit is contained in:
parent
5ef82ddd2f
commit
57a4b51e87
@ -2,11 +2,10 @@
|
||||
|
||||
To run them, use:
|
||||
```
|
||||
TF_ACC=1 go test -tags=e2e ./internal/cloud/e2e/... -ldflags "-X \"github.com/hashicorp/terraform/version.Prerelease=<PRE-RELEASE>\""
|
||||
TFE_TOKEN=<token> TFE_HOSTNAME=<hostname> TF_ACC=1 go test ./internal/cloud/e2e/... -ldflags "-X \"github.com/hashicorp/terraform/version.Prerelease=<PRE-RELEASE>\""
|
||||
```
|
||||
|
||||
Required flags
|
||||
* `-tags=e2e` for running e2e tests.
|
||||
* `TF_ACC=1`. This variable is used as part of terraform for tests that make
|
||||
external network calls. This is needed to run these tests. Without it, the
|
||||
tests do not run.
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -24,7 +21,6 @@ const (
|
||||
type tfCommand struct {
|
||||
command []string
|
||||
expectedCmdOutput string
|
||||
expectedErr string
|
||||
expectError bool
|
||||
userInput []string
|
||||
postInputOutput []string
|
||||
@ -105,7 +101,7 @@ func randomString(t *testing.T) string {
|
||||
}
|
||||
|
||||
func terraformConfigLocalBackend() string {
|
||||
return fmt.Sprintf(`
|
||||
return `
|
||||
terraform {
|
||||
backend "local" {
|
||||
}
|
||||
@ -114,7 +110,7 @@ terraform {
|
||||
output "val" {
|
||||
value = "${terraform.workspace}"
|
||||
}
|
||||
`)
|
||||
`
|
||||
}
|
||||
|
||||
func terraformConfigRemoteBackendName(org, name string) string {
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -27,8 +24,9 @@ var verboseMode bool
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
if !accTest() {
|
||||
// if TF_ACC is not set, we want to skip all these tests.
|
||||
hasRequiredEnvVars := accTest() && hasHostname() && hasToken()
|
||||
if !hasRequiredEnvVars {
|
||||
// if the above three required variables are not set, then skip all tests.
|
||||
return
|
||||
}
|
||||
teardown := setup()
|
||||
@ -44,6 +42,14 @@ func accTest() bool {
|
||||
return os.Getenv("TF_ACC") != ""
|
||||
}
|
||||
|
||||
func hasHostname() bool {
|
||||
return os.Getenv("TFE_HOSTNAME") != ""
|
||||
}
|
||||
|
||||
func hasToken() bool {
|
||||
return os.Getenv("TFE_TOKEN") != ""
|
||||
}
|
||||
|
||||
func setup() func() {
|
||||
tfOutput := flag.Bool("tfoutput", false, "This flag produces the terraform output from tests.")
|
||||
flag.Parse()
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -186,7 +183,6 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
|
||||
for _, op := range tc.operations {
|
||||
op.prep(t, organization.Name, tf.WorkDir())
|
||||
for _, tfCmd := range op.commands {
|
||||
tfCmd.command = append(tfCmd.command)
|
||||
cmd := tf.Cmd(tfCmd.command...)
|
||||
cmd.Stdin = exp.Tty()
|
||||
cmd.Stdout = exp.Tty()
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -705,15 +702,15 @@ func Test_migrate_remote_backend_prefix_to_tfc_name_strategy_multi_workspace(t *
|
||||
if len(wsList.Items) != 3 {
|
||||
t.Fatalf("expected number of workspaces in this org to be 3, but got %d", len(wsList.Items))
|
||||
}
|
||||
ws, empty := getWorkspace(wsList.Items, "cloud-workspace")
|
||||
_, empty := getWorkspace(wsList.Items, "cloud-workspace")
|
||||
if empty {
|
||||
t.Fatalf("expected workspaces to include 'cloud-workspace' but didn't.")
|
||||
}
|
||||
ws, empty = getWorkspace(wsList.Items, "app-one")
|
||||
_, empty = getWorkspace(wsList.Items, "app-one")
|
||||
if empty {
|
||||
t.Fatalf("expected workspaces to include 'app-one' but didn't.")
|
||||
}
|
||||
ws, empty = getWorkspace(wsList.Items, "app-two")
|
||||
_, empty = getWorkspace(wsList.Items, "app-two")
|
||||
if empty {
|
||||
t.Fatalf("expected workspaces to include 'app-two' but didn't.")
|
||||
}
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,6 +1,3 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -10,7 +7,9 @@ import (
|
||||
"testing"
|
||||
|
||||
expect "github.com/Netflix/go-expect"
|
||||
tfe "github.com/hashicorp/go-tfe"
|
||||
"github.com/hashicorp/terraform/internal/e2e"
|
||||
tfversion "github.com/hashicorp/terraform/version"
|
||||
)
|
||||
|
||||
func terraformConfigRequiredVariable(org, name string) string {
|
||||
@ -54,6 +53,10 @@ func Test_cloud_run_variables(t *testing.T) {
|
||||
{
|
||||
prep: func(t *testing.T, orgName, dir string) {
|
||||
wsName := "new-workspace"
|
||||
_ = createWorkspace(t, orgName, tfe.WorkspaceCreateOptions{
|
||||
Name: tfe.String(wsName),
|
||||
TerraformVersion: tfe.String(tfversion.String()),
|
||||
})
|
||||
tfBlock := terraformConfigRequiredVariable(orgName, wsName)
|
||||
writeMainTF(t, tfBlock, dir)
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user