Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use anon structs in tests where applicable #39

Open
MaddieM4 opened this issue Aug 6, 2014 · 0 comments
Open

Use anon structs in tests where applicable #39

MaddieM4 opened this issue Aug 6, 2014 · 0 comments

Comments

@MaddieM4
Copy link
Member

MaddieM4 commented Aug 6, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant