blob: 5adf0141410d8168e088e468295a47c7c9b09b05 [file] [log] [blame]
package tfexec
import (
"context"
"os"
"testing"
"github.com/hashicorp/terraform-exec/tfexec/internal/testutil"
)
func TestOutputCmd(t *testing.T) {
td := testTempDir(t)
defer os.RemoveAll(td)
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
t.Fatal(err)
}
// empty env, to avoid environ mismatch in testing
tf.SetEnv(map[string]string{})
t.Run("defaults", func(t *testing.T) {
outputCmd := tf.outputCmd(context.Background())
assertCmd(t, []string{
"output",
"-no-color",
"-json",
}, nil, outputCmd)
})
t.Run("override all defaults", func(t *testing.T) {
outputCmd := tf.outputCmd(context.Background(),
State("teststate"))
assertCmd(t, []string{
"output",
"-no-color",
"-json",
"-state=teststate",
}, nil, outputCmd)
})
}