-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt: Gate formatting command on 0.7.7
- Loading branch information
1 parent
1100100
commit 78025b1
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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") | ||
} | ||
|
||
expectedErr := &ErrVersionMismatch{ | ||
Actual: "0.7.6", | ||
MinInclusive: "0.7.7", | ||
MaxExclusive: "-", | ||
} | ||
if !errors.Is(err, expectedErr) { | ||
t.Fatalf("error doesn't match: %#v", err) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters