Skip to content

Commit 9ab0a12

Browse files
authored
Use helper.AssertIssues fixed in SDK v0.22 (#246)
See terraform-linters/tflint-plugin-sdk#363
1 parent 5c6449b commit 9ab0a12

File tree

1 file changed

+1
-33
lines changed

1 file changed

+1
-33
lines changed

rules/terraform_required_providers_test.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package rules
22

33
import (
4-
"reflect"
54
"testing"
65

7-
"github.com/google/go-cmp/cmp"
8-
"github.com/google/go-cmp/cmp/cmpopts"
96
"github.com/hashicorp/hcl/v2"
107
"github.com/terraform-linters/tflint-plugin-sdk/helper"
11-
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
128
)
139

1410
func Test_TerraformRequiredProvidersRule(t *testing.T) {
@@ -695,35 +691,7 @@ terraform {
695691
t.Fatalf("Unexpected error occurred: %s", err)
696692
}
697693

698-
// TODO: replace the following assertions without ordering by AssertIssues
699-
// helper.AssertIssues(t, tc.Expected, runner.Runner.(*helper.Runner).Issues)
700-
opts := []cmp.Option{
701-
cmpopts.IgnoreFields(hcl.Pos{}, "Byte"),
702-
cmp.Comparer(func(x, y tflint.Rule) bool {
703-
return reflect.TypeOf(x) == reflect.TypeOf(y)
704-
}),
705-
cmpopts.SortSlices(func(i, j *helper.Issue) bool {
706-
if i.Range.Filename != j.Range.Filename {
707-
return i.Range.Filename < j.Range.Filename
708-
}
709-
if i.Range.Start.Line != j.Range.Start.Line {
710-
return i.Range.Start.Line < j.Range.Start.Line
711-
}
712-
if i.Range.Start.Column != j.Range.Start.Column {
713-
return i.Range.Start.Column < j.Range.Start.Column
714-
}
715-
if i.Range.End.Line != j.Range.End.Line {
716-
return i.Range.End.Line > j.Range.End.Line
717-
}
718-
if i.Range.End.Column != j.Range.End.Column {
719-
return i.Range.End.Column > j.Range.End.Column
720-
}
721-
return i.Message < j.Message
722-
}),
723-
}
724-
if diff := cmp.Diff(tc.Expected, runner.Runner.(*helper.Runner).Issues, opts...); diff != "" {
725-
t.Fatalf("Expected issues are not matched:\n %s\n", diff)
726-
}
694+
helper.AssertIssues(t, tc.Expected, runner.Runner.(*helper.Runner).Issues)
727695
want := map[string]string{}
728696
if tc.Fixed != "" {
729697
want[filename] = tc.Fixed

0 commit comments

Comments
 (0)