Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(pypi): add tests for fetching package from pypi #39

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pip/worker/pypi.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func NewPypiPackageDataFactory(client *helper.Client) PypiPackageDataFactory {
func (pf *pypiPackageDataFactory) GetPackageData(packageJSONURL string) (PypiPackageData, error) {
packageInfo := PypiPackageData{}

packageJSONURL = strings.Replace(packageJSONURL, "pypi.org", "", 1)
packageJSONURL = strings.ReplaceAll(packageJSONURL, "pypi.org", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you edit your commit to explain why this change is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the http client was changed to accept a baseURL, so that external http requests can be mocked, I had to strip off pypi.org from the base url and hence in the first commit, I had introduced

packageJSONURL = strings.Replace(packageJSONURL, "pypi.org", "", 1)

which was later replaced by just to abide by the code style of the codebase.

packageJSONURL = strings.ReplaceAll(packageJSONURL, "pypi.org", "")

I thought the chore prefix to the commit made sense, but I'm open to adding a comment or changing the commit message for more verbosity.

response, err := pf.client.HTTP.Get(fmt.Sprintf("%s%s", pf.client.BaseURL, packageJSONURL))
if err != nil {
return packageInfo, err
Expand Down