Skip to content

Instantly share code, notes, and snippets.

@munjeli
Created June 7, 2020 14:28
Show Gist options
  • Save munjeli/bf33b632a78f453e023ffa83aa3972d1 to your computer and use it in GitHub Desktop.
Save munjeli/bf33b632a78f453e023ffa83aa3972d1 to your computer and use it in GitHub Desktop.
Table Driven Test Live Template
func Test$FUNCTION$(t *testing.T) {
tests := []struct {
desc string
thing {}interface
wantErr bool
} {
{
desc: "",
thing: {}interface{},
wantErr: false,
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
_, err := $FUNCTION$()
if err != nil && !test.wantErr {
t.Errorf("wantErr: %v, got: %v", test.wantErr, err)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment