Testing the Go Package
Let’s learn how to test the Go package.
We'll cover the following
The postGo.go
utility
In order to test the package, we must develop a command-line utility called postGo.go
.
Note: Because
postGo.go
uses an external package, even if we develop that package, we should not forget to download the latest version of that external package usinggo get
orgo get -u
.
Because postGo.go
is used for testing purposes only, we hardcoded most of the data apart from the username of the user we put into the database. All usernames are randomly generated.
Implementation details
The code of postGo.go
is as follows:
Get hands-on with 1400+ tech skills courses.