Update go snippet

Buddy Sandidge 4 years ago
parent af9ac32bdc
commit f3f8f4557d

@ -10,15 +10,32 @@ endsnippet
snippet test "setup test case" ! snippet test "setup test case" !
func Test${1}(t *testing.T) { func Test${1}(t *testing.T) {
type testcase struct { type testcase struct {
name string Name string
setup func(tc *testcase) Setup func(tc *testcase)
} }
tt := []testcase{} tt := []testcase{}
for _, tc := range tt { for _, tc := range tt {
tc := tc tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
tc.setup(&tc) tc.Setup(&tc)
})
}
}
endsnippet
snippet htest "setup hellotech 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 := cutils.Test(t)
t.Parallel()
tc.Setup(&tc)
}) })
} }
} }

Loading…
Cancel
Save