Skip to content

Commit

Permalink
Fix 0.13 no init error issue
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed Aug 14, 2020
1 parent 0af7883 commit 29d826b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tfexec/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func parseError(err error, stderr string) error {
return &ErrCLIUsage{stderr: stderr}
case regexp.MustCompile(`Error: Could not satisfy plugin requirements`).MatchString(stderr):
return &ErrNoInit{stderr: stderr}
case regexp.MustCompile(`Error: Could not load plugin`).MatchString(stderr):
// this string is present in 0.13
return &ErrNoInit{stderr: stderr}
case regexp.MustCompile(`Error: No configuration files`).MatchString(stderr):
return &ErrNoConfig{stderr: stderr}
default:
Expand Down
10 changes: 4 additions & 6 deletions tfexec/internal/e2etest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ func TestShow_errInitRequired(t *testing.T) {
t.Skip("terraform show was added in Terraform 0.12, so test is not valid")
}

var noInit *tfexec.ErrNoInit
_, err := tf.Show(context.Background())
if err == nil {
t.Fatal("expected Show to error, but it did not")
}
if _, ok := err.(*tfexec.ErrNoInit); !ok {
t.Fatalf("expected error %s to be ErrNoInit", err)
if !errors.As(err, &noInit) {
t.Fatalf("expected error ErrNoInit, got %T: %s", err, err)
}
})
}
Expand All @@ -93,7 +91,7 @@ func TestShow_versionMismatch(t *testing.T) {
var mismatch *tfexec.ErrVersionMismatch
_, err := tf.Show(context.Background())
if !errors.As(err, &mismatch) {
t.Fatal("expected version mismatch error")
t.Fatalf("expected version mismatch error, got %T %s", err, err)
}
if mismatch.Actual != "0.11.14" {
t.Fatalf("expected version 0.11.14, got %q", mismatch.Actual)
Expand Down

0 comments on commit 29d826b

Please sign in to comment.