-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
55 lines (45 loc) · 995 Bytes
/
main_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
package main
import (
"io/ioutil"
"path/filepath"
"strings"
"testing"
"github.com/iancoleman/strcase"
"github.com/stretchr/testify/require"
)
func Test(t *testing.T) {
files, err := ioutil.ReadDir("testdata")
require.NoError(t, err)
var tests []string
for _, file := range files {
if file.IsDir() {
continue
}
basename := filepath.Base(file.Name())
if filepath.Ext(basename) != ".go" ||
strings.HasPrefix(basename, "_") ||
strings.HasSuffix(basename, "_options.go") {
continue
}
tests = append(tests, file.Name())
}
for _, test := range tests {
t.Run(test, testFile(test).Helper)
}
}
type testFile string
func (f testFile) Helper(t *testing.T) {
t.Helper()
c := config{
Input: "testdata",
OptionTypename: "Option",
OptionFuncPrefix: "Option",
// concreteOutput: os.Stdout,
StructName: strcase.ToCamel(strings.TrimSuffix(string(f), ".go")),
}
g := generator{
config: c,
}
err := g.Run()
require.NoError(t, err)
}