The MustCreate Pattern for Go Tests

24 points by mtlynch


nickmonad

I think in these cases, I would either ignore the error (username, _ := ...) or write a simple assert(t, err == nil) that makes the if check just one line. Then, fuzz NewUsername separately to handle the cases where the requested username could be invalid and those errors matter.

But hey, decent application of generics and I wouldn't necessarily change this if I saw it in the wild.