test(ios-readplace): assert exact values instead of existence/negatives#923
Closed
FagnerMartinsBrack wants to merge 1 commit into
Closed
test(ios-readplace): assert exact values instead of existence/negatives#923FagnerMartinsBrack wants to merge 1 commit into
FagnerMartinsBrack wants to merge 1 commit into
Conversation
Replace assertions that pass for the wrong reason with ones that pin the actual
value, per the test-driven-design conventions:
- SirenDate: assert the parsed instant equals a known UTC time (and that the
fractional variant is exactly 123 ms later) instead of `XCTAssertNotNil`, and
assert the fixture's `savedAt` parses to its exact instant — a parser that
returned the wrong time previously passed.
- PKCE: assert the challenge's exact length (43) and that every character is in
the base64url alphabet, replacing three `contains("+"/"/"/"=")` negatives that
a wrong-length or wrong-alphabet challenge would still satisfy.
- Login/Signup authorize tests: derive the expected host from
`AppConfig.serverBaseURL` instead of the literal "readplace.com", so the
assertion is environment-agnostic (a prerequisite for running the full suite
under the STAGING build).
Member
Author
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
Three tests passed for the wrong reason — an existence check or a negative assertion that a buggy implementation would still satisfy. This replaces them with assertions that pin the actual value, per the repo's test-driven-design conventions ("Test Behavior, Not Element Existence" / "Avoid Negative Test Assertions").
What changed & why it matters
SirenDateparsing —XCTAssertNotNil(SirenDate.parse(…))passed even if the parser returned the wrong instant (dropped the fractional part, misread the zone). Now it asserts the parsed value equals a known UTC instant, and that the fractional variant is exactly 123 ms later. Same fix for the fixture'ssavedAt(wasXCTAssertNotNil).testChallengeIsURLSafeproved the challenge only by what it didn't contain (+,/,=), so a wrong-length or wrong-alphabet challenge passed. Now it asserts the exact length (43) and a positive base64url-alphabet check, mirroring the verifier test."readplace.com", which is why the full suite can't run under the STAGING build. They now derive the expected host fromAppConfig.serverBaseURL(the same config the code uses), making them environment-agnostic — a prerequisite for a later widening ofmake test-staging.Testing
Full suite green (242 tests), coverage gate passes, STAGING smoke passes.