test: Ensure that empty strings aren't used as IRIs in tests #52
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.
The resources responder and values responder test specs include a number of tests that generate IRIs that are used in subsequent tests. These IRIs have just been stored as strings in mutable variables, initialised to the empty string. A problem I've encountered is that if one test fails, a subsequent test may try to use an empty string as an IRI, resulting in an unbound SPARQL variable, which leads to a very busy triplestore, a massive unwanted query result, and a confusing delay before the test fails.
This pull request replaces those mutable variables with a little class called
MutableTestIri
, which hasget
andset
methods that throw exceptions if the IRI is an empty string, is invalid, or hasn't been set when it's needed. So if a test fails and doesn't set an IRI, a subsequent test that needs the IRI will fail gracefully.