Skip to content

not enough arguments in call to registerPackageData in chapter 3 - pkgregister_test.go #13

@rikyhidayat21

Description

@rikyhidayat21

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions