mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 09:23:09 -06:00
* Update gometalinter * Disable gas linter According to the gas github page: > Gas is still in alpha and accepting feedback from early adopters. We do not > consider it production ready at this time. Generally it seems to shout about a lot of things which aren't very errory, like executing subprocesses with anything other than a hardcoded commandline, and creating directories with anything other than 700 perms.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
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))
|
|
}
|