Skip to content

Instantly share code, notes, and snippets.

@efueyo
Created October 25, 2019 23:46
Show Gist options
  • Save efueyo/de5526b0bdbbe39f4489ce7da8cac9f1 to your computer and use it in GitHub Desktop.
Save efueyo/de5526b0bdbbe39f4489ce7da8cac9f1 to your computer and use it in GitHub Desktop.
HelperFunctions.go
func MustJSONMarshall(t *testing.T, a interface{}) []byte {
res, err := json.Marshal(a)
if err != nil {
t.FatalF("err: %s", err)
}
return res
}
func TestWhatver(t *testing.T) {
elem := MyStruct{Field:"something"}
elemB := MustJSONMarshall(t, elem)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment