This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Conversation
This will make it easier to run the tests once the fixture files move around. If a file is misplaced, the test will fail instead of crashing. Operationally, failing is better than crashing because it generates a list of all misplaced tests, so that they can be addressed in one go. The alternative would be a run tests, tests crash, fix individual file path loop for as many misplaced fixture files there are.
mokagio
commented
Mar 19, 2024
| stub(condition: {request in request.url?.absoluteString == testURLString}) { _ in | ||
| let stubPath = OHPathForFile("empty.json", type(of: self)) | ||
| return fixture(filePath: stubPath!, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) | ||
| return fixture(filePath: stubPath, headers: ["Content-Type" as NSObject: "application/json" as AnyObject]) |
Contributor
Author
There was a problem hiding this comment.
The header dictionary for content type JSON is repeated all over the place.
It could be DRYed in some form. I decided to keep it out because this PR is already noisy. Besides, the focus of this stream of work is to prepare for SPM. DRYing this definition would be useful, but doesn't bring us closer to that goal.
mokagio
commented
Mar 19, 2024
Comment on lines
+149
to
+153
| guard let stubPath = OHPathForFile(files[callCounter], type(of: self)) else { | ||
| XCTFail("Could not find file at path '\(files[callCounter])'.") | ||
| let error = NSError(domain: "RemoteTestCase", code: 0, userInfo: nil) | ||
| return HTTPStubsResponse(error: error) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Had to fail in this way, also returning an error because we're inside a closure and the file path is computed based on the callCounter value.
This was referenced Mar 20, 2024
crazytonyli
approved these changes
Mar 24, 2024
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
This will make it easier to run the tests once the fixture files move around.
If a file is misplaced, the test will fail instead of crashing.
Operationally, failing is better than crashing because it generates a
list of all misplaced tests, so that they can be addressed in one go. The alternative would be a run tests, tests crash, fix individual file path loop for as many misplaced fixture files there are.
Unfortunately, the diff is extensive. However, with the exception of
RemoteTestCase.swiftwhich changed in isolation in 007e11a, the pattern for all the changes is the same:From:
To:
Testing Details
Green CI. This is only a unit tests implementation change.
Next up
Basically, cherry-pick the work from #738 but in a neat and reviewable order:
Sources/andTests/Bundlehelper that differentiates between SPM and CocoaPods installationsCHANGELOG.mdif necessary. — N.A.