forked from alecthomas/gometalinter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
issue_test.go
39 lines (34 loc) · 1.12 KB
/
issue_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSortedIssues(t *testing.T) {
actual := []*Issue{
{Path: newIssuePath("", "b.go"), Line: 5, Col: 1},
{Path: newIssuePath("", "a.go"), Line: 3, Col: 2},
{Path: newIssuePath("", "b.go"), Line: 1, Col: 3},
{Path: newIssuePath("", "a.go"), Line: 1, Col: 4},
}
issues := &sortedIssues{
issues: actual,
order: []string{"path", "line", "column"},
}
sort.Sort(issues)
expected := []*Issue{
{Path: newIssuePath("", "a.go"), Line: 1, Col: 4},
{Path: newIssuePath("", "a.go"), Line: 3, Col: 2},
{Path: newIssuePath( "", "b.go"), Line: 1, Col: 3},
{Path: newIssuePath( "", "b.go"), Line: 5, Col: 1},
}
require.Equal(t, expected, actual)
}
func TestCompareOrderWithMessage(t *testing.T) {
order := []string{"path", "line", "column", "message"}
issueM := Issue{Path: newIssuePath("", "file.go"), Message: "message"}
issueU := Issue{Path: newIssuePath("", "file.go"), Message: "unknown"}
assert.True(t, CompareIssue(issueM, issueU, order))
assert.False(t, CompareIssue(issueU, issueM, order))
}