Creating the To-Do Test File
Learn how to define the test cases in the to-do application.
We'll cover the following...
The code for the to-do API is complete. Let’s write some tests to ensure it’s working properly.
Creating the todo_test.go file
Let’s start by adding the package definition to a new file named todo_test.go:
package todo_test
Adding the package
In general, all files in the same directory must belong to the same Go package.
An exception to this rule is when writing tests. We can define a different
package for our tests to access only the exported types, variables, and
functions from the package we’re testing. This is a common practice when
testing libraries because it ensures the tests ...
Ask