Created
June 7, 2020 14:28
-
-
Save munjeli/bf33b632a78f453e023ffa83aa3972d1 to your computer and use it in GitHub Desktop.
Table Driven Test Live Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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