Last active
April 14, 2017 17:07
-
-
Save mattmc3/eb39dfb9a59f1222c154e80311dcdaa4 to your computer and use it in GitHub Desktop.
Go: unittest method template
This file contains 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{{THING}}(t *testing.T) { | |
var tests = []struct { | |
input string | |
expected string | |
}{ | |
{``, ``}, | |
} | |
for _, tt := range tests { | |
method := fmt.Sprintf(`{{THING}}(%#v)`, tt.input) | |
actual, err := {{THING}}(tt.input) | |
if err != nil { | |
t.Errorf(`%v errored unexpectedly: %#v`, method, err.Error()) | |
} else if !reflect.DeepEqual(actual, tt.expected) { | |
t.Errorf(`%v == %#v; want %#v`, method, actual, tt.expected) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment