Make tests for URL load check rule functions self contained #963
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Several rules check whether URLs provided in project metadata load.
Previously, the handling of various HTTP response status codes of these rule functions was tested by using the convenient httpstat.us site. Unfortunately the maintainers of that site shut it down months ago due to abuse. This caused the spurious failure of the unit tests. Although the httpstat.us maintainers state that they plan to eventually resume service, there hasn't been any indication of progress on that front.
So it will be best to make the tests self contained, without any dependence on an external site. This is accomplished by creating a local HTTP server that responds with the intended status code. Unfortunately this does require the addition of code to the test in order to generate test data on the fly in order to reference the arbitrary port of the test server.