|
|
|
# chezmoi:template:left-delimiter=#{{
|
|
|
|
#{{- /* vim: filetype=snippets */ -}}
|
|
|
|
#{{- if lookPath "go" -}}
|
|
|
|
snippet ignore "ignore function" !
|
|
|
|
func(...any) {}(${1})
|
|
|
|
endsnippet
|
|
|
|
snippet ctx "context" !
|
|
|
|
ctx context.Context
|
|
|
|
endsnippet
|
|
|
|
snippet e "error wrapper" !
|
|
|
|
e := wrap(".${1}")
|
|
|
|
endsnippet
|
|
|
|
snippet test "setup test case" !
|
|
|
|
func Test${1}(t *testing.T) {
|
|
|
|
type testcase struct {
|
|
|
|
Name string
|
|
|
|
Setup func(tc *testcase)
|
|
|
|
}
|
|
|
|
tt := []testcase{}
|
|
|
|
for _, tc := range tt {
|
|
|
|
tc := tc
|
|
|
|
t.Run(tc.Name, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
tc.Setup(&tc)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet htest "setup context test case" !
|
|
|
|
func Test${1}(t *testing.T) {
|
|
|
|
type testcase struct {
|
|
|
|
Name string
|
|
|
|
Setup func(tc *testcase)
|
|
|
|
}
|
|
|
|
|
|
|
|
tt := []testcase{}
|
|
|
|
|
|
|
|
for _, tc := range tt {
|
|
|
|
tc := tc
|
|
|
|
t.Run(tc.Name, func(t *testing.T) {
|
|
|
|
ctx, a, ctrl := utils.Test(t)
|
|
|
|
t.Parallel()
|
|
|
|
tc.Setup(&tc)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
#{{- end }}
|