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

Test download of multiple URLs #29

Merged
merged 45 commits into from
Feb 5, 2022
Merged

Test download of multiple URLs #29

merged 45 commits into from
Feb 5, 2022

Conversation

nappex
Copy link
Collaborator

@nappex nappex commented Jan 16, 2022

fix #26

From @Glutexo: This required a slight change in the executive code so that the download function can accept a list of URLs without initializing the real environment application.

	- the code can not be tested because of func main and constants
	  (resp. atrributes)
	- add on func more which can be tested easier than main
	- add two vars, output file and input file
	- improve test to multiply URLs to handle new func with two args
@nappex nappex marked this pull request as ready for review January 19, 2022 13:12
lib/onigumo.ex Outdated Show resolved Hide resolved
lib/onigumo.ex Outdated Show resolved Hide resolved
test/onigumo_test.exs Outdated Show resolved Hide resolved
lib/onigumo.ex Outdated Show resolved Hide resolved
Co-authored-by: Glutexo <driezasson@me.com>
@nappex nappex requested a review from Glutexo January 20, 2022 10:38
@Glutexo
Copy link
Owner

Glutexo commented Jan 21, 2022

I pushed some more cleanup with a goal being minimize the amount of changes even if that would mean more things to fix up in a follow-up pull requests. Such reverts are:

I did some more changes that may be worth more cleaning, but I am still trying to minimize the number of changes. Those are:

  • Renamed the save_urls_contents/1 method to download/1. It does not clash with the other download methods because of its different signature. To me it feels correct as the URLs loaded from the file are sort of a default value. d05f903
  • Added a is_bitstring guard to the single URL download/2 for symmetry with the multiple URLs counterpart.
  • Change test URLs from onigumo.org to onigumo.local to prevent hitting a real-world servers in case we’d break our mocking. ffc13a7 Extracted to Change test URL domain to local #48.
  • Improved the test names a bit. 5b5684b
  • Replaced the @url_1 and @url_2 constants with a single list @urls. That adds some complexity because Enum.at/2 is needed to access the elements. It however introduces nice semantics with Enum.at(@urls, -1) to grab the last URL from the list. This will need some cleanup though. 4373a3b
  • Removed non-descriptive comments with no real added value. ef2dde3
  • Used the actual test URL count as an argument for mock expect/4. 6263673
  • Used the actual test URL count to assert HTTP responses. 63604f4
  • Added missing HTTP response assertion. 63604f4

Please review and squash+merge if 🆗 .

@Glutexo Glutexo assigned nappex and unassigned nappex Jan 21, 2022
@nappex
Copy link
Collaborator Author

nappex commented Jan 29, 2022

check the merge in commit c38833c, please. @Glutexo

Copy link
Collaborator Author

@nappex nappex left a comment

Choose a reason for hiding this comment

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

Check this merge, please @Glutexo

@Glutexo
Copy link
Owner

Glutexo commented Jan 29, 2022

The c38833c commit only resolves the conflicting lines. A full merge should however bring the introduced change, here usage of the new get!/1 function, to the existing code. It can be either done as a part of the merge commit, or in a separate follow-up commit.

Now, only the “download a single URL” test uses the mock get!/1 function. The remaining tests that were introduced in this pull request and thus did not cause a merge conflict however still use an inline lambda function. This function is the same in all the tests.

@nappex
Copy link
Collaborator Author

nappex commented Jan 29, 2022

The c38833c commit only resolves the conflicting lines. A full merge should however bring the introduced change, here usage of the new get!/1 function, to the existing code. It can be either done as a part of the merge commit, or in a separate follow-up commit.

Now, only the “download a single URL” test uses the mock get!/1 function. The remaining tests that were introduced in this pull request and thus did not cause a merge conflict however still use an inline lambda function. This function is the same in all the tests.

* [x]  [“download a single URL”](https://github.com/Glutexo/onigumo/commit/c38833c4531c92bd2d50555c478150944c0d99ee#diff-f6d51c7b96560cf0270cb7e8e078d59afb32389bebe1079e22b586a9e3480baeR16)

* [x]  [“download multiple URLs”](https://github.com/Glutexo/onigumo/commit/c38833c4531c92bd2d50555c478150944c0d99ee#diff-f6d51c7b96560cf0270cb7e8e078d59afb32389bebe1079e22b586a9e3480baeR26)

* [x]  [“download URLs from the input file”](https://github.com/Glutexo/onigumo/commit/c38833c4531c92bd2d50555c478150944c0d99ee#diff-f6d51c7b96560cf0270cb7e8e078d59afb32389bebe1079e22b586a9e3480baeR48)

Yes you are absolutely right, Sorry and thanks for check.
See e12d44c

Copy link
Owner

@Glutexo Glutexo left a comment

Choose a reason for hiding this comment

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

You nailed it! Requesting just some formatting changes.

test/onigumo_test.exs Outdated Show resolved Hide resolved
test/onigumo_test.exs Outdated Show resolved Hide resolved
@nappex
Copy link
Collaborator Author

nappex commented Jan 29, 2022

Merged test semantic 23901c4

Co-authored-by: Glutexo <driezasson@me.com>
Copy link
Owner

@Glutexo Glutexo left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. The last merge looks good. Reverting to ✅ .

@nappex
Copy link
Collaborator Author

nappex commented Jan 29, 2022

Thanks for the fix. The last merge looks good. Reverting to white_check_mark .

grrhh, stupid mistakes caused by my haste. thanks for review.

@nappex
Copy link
Collaborator Author

nappex commented Jan 29, 2022

merged added the body func -> e2064af

test/onigumo_test.exs Outdated Show resolved Hide resolved
@Glutexo
Copy link
Owner

Glutexo commented Jan 29, 2022

Awesome! One step closer.

@Glutexo
Copy link
Owner

Glutexo commented Jan 29, 2022

The only thing that has been extracted from this pull request and is not merged yet is:

That pull request is the only one I’d insist on merging prior to merging this one.

My ideas for improvement that have not been merged yet are:

Those can be merged first, but they do not necessarily block this pull request. If you’d like to have your pull request merged, I’ll happily update those mentioned after that.

All other currently open pull requests are not related to this one and can be addressed completely indepentently.

@Glutexo
Copy link
Owner

Glutexo commented Jan 30, 2022

To make the merge history more clear. These merges addressed things that were once already in this pull request, but have been extracted to minimize the number of changes:

Opposed to that, the following merges brought in changes from pull requests containing either my own improvement ideas or things that were only discussed. Those may have sourced from working on this pull request, but never were a part of it.

Providing these lists to distinguish what was a part of this pull request and is this good to address prior to merging this one. Other things don’t need to block this, although it is perfectly possible to merge them first as they are generally small changes.

Copy link
Owner

@Glutexo Glutexo left a comment

Choose a reason for hiding this comment

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

I have only a suggestion to keep variable lifespan as short as possible. That means, initialize a variable as close to its first (or even only) usage as possible. I don’t insist on fixing it in this pull request. Either fix and merge, or just merge.

test/onigumo_test.exs Outdated Show resolved Hide resolved
test/onigumo_test.exs Show resolved Hide resolved
test/onigumo_test.exs Show resolved Hide resolved
test/onigumo_test.exs Show resolved Hide resolved
test/onigumo_test.exs Show resolved Hide resolved
@Glutexo
Copy link
Owner

Glutexo commented Feb 3, 2022

Wow. The whitespace fix in e914eb7 created a fat conflict. Update: Resolved.

@Glutexo Glutexo merged commit f2df4cb into Glutexo:elixir Feb 5, 2022
@Glutexo Glutexo deleted the add_tests branch February 5, 2022 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test download of multiple URLs
2 participants