/
tracegen_test.go
58 lines (48 loc) · 957 Bytes
/
tracegen_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
57
58
package tracegen
import (
"bytes"
"embed"
"testing"
"github.com/stretchr/testify/require"
)
//go:embed testdata
var testdata embed.FS
func TestRun(t *testing.T) {
type args struct {
source string
}
type want struct {
file string
}
test := func(args args, want want) func(t *testing.T) {
return func(t *testing.T) {
t.Helper()
data, err := testdata.ReadFile(want.file)
require.NoError(t, err)
got := &bytes.Buffer{}
err = Run(args.source, got)
require.NoError(t, err)
require.Equal(t, string(data), got.String())
}
}
tests := []struct {
name string
args args
want want
}{
{
name: "empty",
args: args{source: "testdata/empty.go"},
want: want{file: "testdata/empty_tracegen.go"},
},
{
name: "full",
args: args{source: "testdata/full.go"},
want: want{file: "testdata/full_tracegen.go"},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, test(tt.args, tt.want))
}
}