Skip to content

test(ios-readplace): assert exact values instead of existence/negatives#923

Closed
FagnerMartinsBrack wants to merge 1 commit into
ios/untested-seamsfrom
ios/test-quality
Closed

test(ios-readplace): assert exact values instead of existence/negatives#923
FagnerMartinsBrack wants to merge 1 commit into
ios/untested-seamsfrom
ios/test-quality

Conversation

@FagnerMartinsBrack

Copy link
Copy Markdown
Member

Stacked on #922 (base = ios/untested-seams). Review/merge after it. Test-only, no production changes.

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

  • SirenDate parsingXCTAssertNotNil(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's savedAt (was XCTAssertNotNil).
  • PKCE challengetestChallengeIsURLSafe proved 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.
  • Login/Signup authorize — the tests pinned the literal host "readplace.com", which is why the full suite can't run under the STAGING build. They now derive the expected host from AppConfig.serverBaseURL (the same config the code uses), making them environment-agnostic — a prerequisite for a later widening of make test-staging.

Testing

Full suite green (242 tests), coverage gate passes, STAGING smoke passes.

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).
@FagnerMartinsBrack

Copy link
Copy Markdown
Member Author

Superseded by #927, which consolidates all 9 stacked PRs into one PR targeting main (so CI runs and it's independently deployable). See #927 for the full description.

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.

1 participant