|
1 | 1 | package rules |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "reflect" |
5 | 4 | "testing" |
6 | 5 |
|
7 | | - "github.com/google/go-cmp/cmp" |
8 | | - "github.com/google/go-cmp/cmp/cmpopts" |
9 | 6 | "github.com/hashicorp/hcl/v2" |
10 | 7 | "github.com/terraform-linters/tflint-plugin-sdk/helper" |
11 | | - "github.com/terraform-linters/tflint-plugin-sdk/tflint" |
12 | 8 | ) |
13 | 9 |
|
14 | 10 | func Test_TerraformRequiredProvidersRule(t *testing.T) { |
@@ -695,35 +691,7 @@ terraform { |
695 | 691 | t.Fatalf("Unexpected error occurred: %s", err) |
696 | 692 | } |
697 | 693 |
|
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) |
727 | 695 | want := map[string]string{} |
728 | 696 | if tc.Fixed != "" { |
729 | 697 | want[filename] = tc.Fixed |
|
0 commit comments