-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfailure_test.go
54 lines (50 loc) · 1.15 KB
/
failure_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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"go/token"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFormat(t *testing.T) {
tests := []struct {
name string
failure failure
expected string
}{
{
name: "error severity",
failure: failure{
Position: struct {
Start token.Position
End token.Position
}{
Start: token.Position{Filename: "main.go", Line: 10, Column: 5},
End: token.Position{Line: 10, Column: 10},
},
Failure: "some error",
Severity: "error",
},
expected: "::error file=main.go,line=10,endLine=10,col=5,endColumn=10::some error",
},
{
name: "warning severity",
failure: failure{
Position: struct {
Start token.Position
End token.Position
}{
Start: token.Position{Filename: "main.go", Line: 20, Column: 15},
End: token.Position{Line: 20, Column: 20},
},
Failure: "some warning",
Severity: "warning",
},
expected: "::warning file=main.go,line=20,endLine=20,col=15,endColumn=20::some warning",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.failure.Format()
assert.Equal(t, tt.expected, got)
})
}
}