A useful testing pattern, which apparently is common knowledge in the Go community but new to me, is the use of anon structs in tests.
func TestXYZ(t *testing.T) {
tests := []struct{
Description string
Status int
ExpectedOutput string
}{
{
Description: "Foo does bar",
Status: 5,
ExpectedOutput: "xyzxyzxyzxyzxyz",
},
{ ... },
}
}
There are a few tests, particularly in the TimestampTracker tests (IIRC), where this would have been much more idiomatic than a named type. Research where this makes sense, and rewrite the tests to use this style.
A useful testing pattern, which apparently is common knowledge in the Go community but new to me, is the use of anon structs in tests.
There are a few tests, particularly in the TimestampTracker tests (IIRC), where this would have been much more idiomatic than a named type. Research where this makes sense, and rewrite the tests to use this style.