emersion / go-imap

📥 An IMAP library for clients and servers
MIT License
2.1k stars 297 forks source link

idea: fixtures in tests (or simething like that) #570

Closed Rikkuru closed 11 months ago

Rikkuru commented 11 months ago

So I recently heard about a guy who created a lib that tries to add fixtures to golang unit tests - https://github.com/rekby/fixenv

Did not have a chance to tesk it yet but the approach seems fitting for this project ? (there are some examples in readme )

If we need to run a test with 2 users and setup their folders and messages but we might just write fixtures that create those objects and delete them after the test is done. Object can be created just by calling a fixture in test instead of adding more and more serivice code in newClientServerPair or adding other pairs.

You probabli have a plan for tests , just thought you to mention it

emersion commented 11 months ago

I'd prefer to not add any extra deps for testing, and write tests similarly to the stdlib. I don't think we need to cleanup the server after tests, creating a new in-memory server is very cheap.

Rikkuru commented 11 months ago

ok ok