Created
October 25, 2019 23:46
-
-
Save efueyo/de5526b0bdbbe39f4489ce7da8cac9f1 to your computer and use it in GitHub Desktop.
HelperFunctions.go
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 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