forked from x-motemen/gore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errfilter_test.go
56 lines (53 loc) · 1.18 KB
/
errfilter_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
55
56
package gore
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
func TestErrFilter(t *testing.T) {
testCases := []struct {
id, src, expected string
}{
{
"simple",
"foobar",
"foobar",
},
{
"new line",
"foobar\nbaz\nqux\n",
"foobar\nbaz\nqux\n",
},
{
"command-line-arguments",
"# command-line-arguments foo\nbar\nbuild command-line-arguments: baz\nqux",
"bar\nbaz\nqux",
},
{
"gore_session.go",
"/tmp/gore_session.go:10:24: undefined: foo",
"undefined: foo",
},
{
"command-line-arguments and gore_session.go",
"# command-line-arguments foo\n/tmp/gore_session.go:10:24: undefined: foo",
"undefined: foo",
},
{
"no module dependencies warning",
"warning: pattern \"all\" matched no module dependencies\nwarning: pattern \"all\" matched no module dependencie",
"warning: pattern \"all\" matched no module dependencie",
},
}
for _, tc := range testCases {
t.Run(tc.id, func(t *testing.T) {
out := new(bytes.Buffer)
w := newErrFilter(out)
_, err := w.Write([]byte(tc.src))
require.NoError(t, err)
err = w.Close()
require.NoError(t, err)
require.Equal(t, tc.expected, out.String())
})
}
}