fmt: Gate formatting command on 0.7.7 (#88)

* fmt: Gate formatting command on 0.7.7

* avoid error field checking

* replace errors.Is with errors.As
diff --git a/tfexec/fmt.go b/tfexec/fmt.go
index 64473a5..d80a39b 100644
--- a/tfexec/fmt.go
+++ b/tfexec/fmt.go
@@ -121,6 +121,11 @@
 }
 
 func (tf *Terraform) formatCmd(ctx context.Context, args []string, opts ...FormatOption) (*exec.Cmd, error) {
+	err := tf.compatible(ctx, tf0_7_7, nil)
+	if err != nil {
+		return nil, fmt.Errorf("fmt was first introduced in Terraform 0.7.7: %w", err)
+	}
+
 	c := defaultFormatConfig
 
 	for _, o := range opts {
diff --git a/tfexec/fmt_test.go b/tfexec/fmt_test.go
new file mode 100644
index 0000000..517c2d0
--- /dev/null
+++ b/tfexec/fmt_test.go
@@ -0,0 +1,33 @@
+package tfexec
+
+import (
+	"context"
+	"errors"
+	"os"
+	"testing"
+)
+
+func TestFormat(t *testing.T) {
+	td := testTempDir(t)
+	defer os.RemoveAll(td)
+
+	tf, err := NewTerraform(td, tfVersion(t, "0.7.6"))
+	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")
+		}
+
+		var expectedErr *ErrVersionMismatch
+		if !errors.As(err, &expectedErr) {
+			t.Fatalf("error doesn't match: %#v", err)
+		}
+	})
+}
diff --git a/tfexec/version.go b/tfexec/version.go
index ae1dd5f..6f3f139 100644
--- a/tfexec/version.go
+++ b/tfexec/version.go
@@ -12,6 +12,7 @@
 )
 
 var (
+	tf0_7_7  = version.Must(version.NewVersion("0.7.7"))
 	tf0_12_0 = version.Must(version.NewVersion("0.12.0"))
 	tf0_13_0 = version.Must(version.NewVersion("0.13.0"))
 )