Goal
- Sleep. Rest. Go if I am awake. Have a meeting later in the day.
2025-02-05 10:00
- Too shuffly. trying to read the Go CLI book
- Note to Self, regarding how to test and what to test *
When you tested the todo tool in Testing the Initial CLI Implementation, on
page 23, you wrote something similar to an integration test by compiling the
tool and running it in the test cases. This was necessary as all the code was
part of the main() function, which can’t be tested.
For this application, you’ll take a different approach; you’ll write individual unit tests for each function, and use an integration test to test the run() function. You can do this now because the run() function returns values that can be used in tests.
This means you’re intentionally not testing some of the code that’s still in the main() function, such as the block that parses the command-line flags. You don’t have to write tests for that code because you can assume it’s already been tested by the Go team. When using external libraries and packages, trust that they have been tested by the developers who provided them. If you don’t trust the developers, don’t use the library.
This also means you don’t need to write unit tests for the saveHTML() function since it’s essentially a wrapper around a function from Go’s standard library. Its behavior is assured in the integration test you’ll write.* - 11:56: Note to Self, ok if everything does not match the book. You aren’t completely in control
2025-02-05 12:00
- Client meeting
2025-02-05 17:50
- I keep thinking, nothing is getting done, and then I have to remind myself I’m convalescing 😂
Feedback on this post?
Mail me at feedback at this domain.
P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.