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 Onigumo.Downloader.main #139

Merged
merged 7 commits into from
Nov 19, 2022
Merged

✅ Test Onigumo.Downloader.main #139

merged 7 commits into from
Nov 19, 2022

Conversation

Glutexo
Copy link
Owner

@Glutexo Glutexo commented Aug 16, 2022

The application

  • starts the HTTPClient,
  • downloads the URLs.

The new test is very similar to download_urls_from_file. In this case, the Stream runs automatically, and the test only verifies the result. The assertion of the Stream.run return value is redundant, but in another test case, we check that File.write! returns :ok, although there is no other possible return value.

The assertion of HTTPoison.start is mandatory: Mox requires all mock calls to have an expect clause. There is no need to test that separately then.

Fixes #56.

The application

- starts the HTTPClient,
- downloads the URLs.
@Glutexo Glutexo added the tests label Aug 16, 2022
@Glutexo Glutexo requested a review from nappex August 16, 2022 09:47
@Glutexo Glutexo self-assigned this Aug 16, 2022
test/onigumo_test.exs Outdated Show resolved Hide resolved
test/onigumo_test.exs Outdated Show resolved Hide resolved
@@ -9,6 +9,22 @@ defmodule OnigumoTest do

setup(:verify_on_exit!)

@tag :tmp_dir
test("run the download", %{tmp_dir: tmp_dir}) do
Copy link
Owner Author

Choose a reason for hiding this comment

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

I could not find a more suitable description for the test. Do you have any ideas?

Copy link
Collaborator

@nappex nappex Oct 28, 2022

Choose a reason for hiding this comment

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

Consider proposal #150 , if we come to reach an angreement on that we have to fix that in another PR of course.

my suggestions to

Onigumo.Downloader.main:

  • start
  • init
  • trigger

"run the download"

  • activate downloading
  • start download process
  • integration test for downloader
  • check download process

Copy link
Collaborator

Choose a reason for hiding this comment

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

We discussed personally, there is a option to split func main to init and run, where start should be located in init and rest in main....

Copy link
Collaborator

Choose a reason for hiding this comment

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

So far we keep the name main

Copy link
Owner Author

Choose a reason for hiding this comment

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

We kept main because the Downloader is essentialy a standalone application and the main function is its entry points. The caller does not care about what the module does. main is a traditional name from the ages of C and Java.

Copy link
Owner Author

Choose a reason for hiding this comment

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

The new name of the tests is „run Downloader,“ because what we test here is that the Downloader does its job. The fact that it loadts the URLs from a file and then downloads them is a mere technical detail.

@Glutexo Glutexo changed the title Test Onigumo.Downloader.main ✅ Test Onigumo.Downloader.main Aug 16, 2022
@nappex
Copy link
Collaborator

nappex commented Oct 28, 2022

  • Solve return value :ok
  • Write better description text for test
  • try to rename main to more suitable one

@Glutexo
Copy link
Owner Author

Glutexo commented Nov 19, 2022

Your changes are great, @nappex! Feel free to ✅ .

@nappex nappex merged commit 1c27e0b into master Nov 19, 2022
@nappex nappex deleted the test-main branch November 19, 2022 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✅ Test main
2 participants