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

Fixing some tests. #370

Merged
merged 1 commit into from
Jul 27, 2023
Merged

Fixing some tests. #370

merged 1 commit into from
Jul 27, 2023

Conversation

caiosba
Copy link
Contributor

@caiosba caiosba commented Jul 27, 2023

Description

Some tests are failing because https://ca.ios.ba doesn't have HTTPS enabled at the moment. In any case, it's better to rely in another URL that the team has more control over, so I replaced all instances by meedan.com.

How has this been tested?

The build should be fixed with these changes.

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

Some tests are failing because https://ca.ios.ba doesn't have HTTPS enabled at the moment. In any case, it's better to rely in another URL that the team has more control over, so I replaced all instances by meedan.com.
@codeclimate
Copy link

codeclimate bot commented Jul 27, 2023

Code Climate has analyzed commit d3742cb and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 98.0% (0.0% change).

View more on Code Climate.

url = 'https://ca.ios.ba/files/others/test.php' # This link has a sleep(10) function
timeout = '2'
api_key = create_api_key application_settings: { config: { timeout: timeout }}
url = 'https://meedan.com/'
Copy link
Contributor

Choose a reason for hiding this comment

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

there was a sleep function in the link before, that isn't needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I reduced the config.timeout to compensate.

@lw = Lapis::Webhook.new('https://ca.ios.ba/', { foo: 'bar' }.to_json)
super
url = 'https://webhook.net/'
@lw = Lapis::Webhook.new(url, { foo: 'bar' }.to_json)
Copy link
Contributor

Choose a reason for hiding this comment

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

here super isn't 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.

Thanks for catching, but no, it was intended... super was not needed for that suite, so it was just making things slightly slower and could lead to surprises too.

assert_equal 'Timeout', JSON.parse(@response.body)['data']['error']['message']
assert_response 200
end

test "should return success even if media could not be instantiated" do
authenticate_with_token
Media.expects(:new).raises(Net::ReadTimeout)
get :index, params: { url: 'http://ca.ios.ba/files/meedan/random.php', format: :json, refresh: '1' }
get :index, params: { url: 'https://meedan.com', format: :json, refresh: '1' }
Copy link
Contributor

Choose a reason for hiding this comment

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

here the random.php isn't needed as well? why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The URL in that case could be any, because the method is mocked anyway: Media.expects(:new).raises(Net::ReadTimeout).

Copy link
Contributor

@vasconsaurus vasconsaurus left a comment

Choose a reason for hiding this comment

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

thank you for the patience and answers 😁

@caiosba
Copy link
Contributor Author

caiosba commented Jul 27, 2023

Thanks @vasconsaurus for the thoroughly review! :)

@caiosba caiosba merged commit 0158587 into develop Jul 27, 2023
4 checks passed
@caiosba caiosba deleted the fix/tests branch July 27, 2023 17:01
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.

2 participants