4 ms·
Here is an idea for a unit test for this code. Pass in an order, assert the pizza that comes out is correct. The entire function is a unit which can fit on my
by jpc0 3y ago
Here is an idea for a unit test for this code.
Pass in an order, assert the pizza that comes out is correct.
The entire function is a unit which can fit on my phone screen and has no external dependencies other than possibly oven, which was discussed in the article, it should probably have been passed in, aka dependency injection.
- latchkey 3y agoSince the example was golang, I personally love uberFX to define modules and dependencies between modules. When you do it that way, unit tests become really easy. It isn't necessary with golang to do this at all, but it really helps build consistent structure throughout the entire app, so I do it. Speaking from personal experience. I built a small golang process that ran on around 25k worker machines. It had to be bug free cause if it crashed and stopped running, it meant updating a whole lot of computers across multiple data centers, by hand. We unit tested everything and the project worked out really well because of that.
- deleted 3y ago[deleted]