Skip to content

Commit

Permalink
try newer versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoe committed Aug 18, 2022
1 parent f06fcd5 commit c7d0793
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -37,7 +37,7 @@ jobs:
# combined due to slowness of Go install
macosbuildtest:
macos:
xcode: "12.5.1"
xcode: "13.4.1"
steps:
- macos_install_go
- checkout
Expand Down
40 changes: 30 additions & 10 deletions tfexec/fmt_test.go
Expand Up @@ -2,35 +2,55 @@ package tfexec

import (
"context"
"errors"
"runtime"
"testing"

"github.com/hashicorp/terraform-exec/tfexec/internal/testutil"
)

func TestFormat(t *testing.T) {
func TestFormatCmd(t *testing.T) {
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
t.Skip("Terraform for darwin/arm64 is not available until v1")
}

td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, "0.7.6"))
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1_1))
if err != nil {
t.Fatal(err)
}

// empty env, to avoid environ mismatch in testing
tf.SetEnv(map[string]string{})

t.Run("too old version", func(t *testing.T) {
_, err := tf.formatCmd(context.Background(), []string{})
if err == nil {
t.Fatal("expected old version to fail")
t.Run("defaults", func(t *testing.T) {
fmtCmd, err := tf.formatCmd(context.Background(), []string{})
if err != nil {
t.Fatal(err)
}

var expectedErr *ErrVersionMismatch
if !errors.As(err, &expectedErr) {
t.Fatalf("error doesn't match: %#v", err)
assertCmd(t, []string{
"fmt",
"-no-color",
}, nil, fmtCmd)
})

t.Run("override all defaults", func(t *testing.T) {
fmtCmd, err := tf.formatCmd(context.Background(),
[]string{"string1", "string2"},
Recursive(true),
Dir("mydir"))
if err != nil {
t.Fatal(err)
}

assertCmd(t, []string{
"fmt",
"-no-color",
"string1",
"string2",
"-recursive",
"mydir",
}, nil, fmtCmd)
})
}
29 changes: 0 additions & 29 deletions tfexec/workspace_show_test.go
Expand Up @@ -2,40 +2,11 @@ package tfexec

import (
"context"
"errors"
"runtime"
"testing"

"github.com/hashicorp/terraform-exec/tfexec/internal/testutil"
)

func TestWorkspaceShowCmd_v012(t *testing.T) {
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
t.Skip("Terraform for darwin/arm64 is not available until v1")
}

td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, "0.9.11"))
if err != nil {
t.Fatal(err)
}

// empty env, to avoid environ mismatch in testing
tf.SetEnv(map[string]string{})

_, err = tf.workspaceShowCmd(context.Background())
if err == nil {
t.Fatal("expected old version to fail")
}

var expectedErr *ErrVersionMismatch
if !errors.As(err, &expectedErr) {
t.Fatalf("error doesn't match: %#v", err)
}

}

func TestWorkspaceShowCmd_v1(t *testing.T) {
td := t.TempDir()

Expand Down

0 comments on commit c7d0793

Please sign in to comment.