In the book Practical Go chapter 3 - pkgregister-data/pkgregister_test.go, we only give single parameters for this code:
func TestRegisterPackageData(t *testing.T) {
// ...
pResult, err := registerPackageData(ts.URL)
// ...
}
It will throw an error when running the test because of not enough arguments in call to registerPackageData.
# github.com/rikyhidayat21/pkgregister-data [github.com/rikyhidayat21/pkgregister-data.test]
/Users/riky/Dev/learning-go/goprac/ch3/pkgregister-data/pkgregister_test.go:55:38: not enough arguments in call to registerPackageData
have (string)
want (*http.Client, string, pkgData)
FAIL github.com/rikyhidayat21/pkgregister-data [build failed]
FAIL
The solution we need to add appropriate parameters as it is.
It should be like this:
func TestRegisterPackageData(t *testing.T) {
// ...
pResult, err := registerPackageData(createHTTPClientWithTimeout(1000), ts.URL, p)
// ...
}
Then if we run the test, now it will be pass.