fix(tests): repair admin_team_lookup_test fixtures (CI failures from #57)#58
Merged
Merged
Conversation
CI on the support-staging deploy caught three bugs in
api/tests/admin_team_lookup_test.rs that were masked locally because no
Postgres was available to actually run integration tests before pushing.
All three were in the test fixtures or a single test's query string,
not in production code.
1. `test_search_matches_substring_case_insensitive`
Team name was "Joes Diner {uuid}" and query was "joes {uuid[..8]}",
but those substrings don't appear consecutively in the team name —
"Diner " sits between them. Renamed teams to use a hyphen joiner
("JoesDiner-{uuid}") so a single contiguous substring matches.
2. `test_search_aggregates_admin_emails` — FK violation on
`team_users_user_pubkey_fkey` when `add_member` referenced admin2 /
member who weren't actually in `users`. The unique index on `users`
is on `pubkey` alone (`users_pubkey_idx`), not `(pubkey, tenant_id)`,
so the original `ON CONFLICT (pubkey, tenant_id)` was a hard parse
error that the `let _ = ...` was silently swallowing. Use
`ON CONFLICT (pubkey) DO UPDATE` to match the actual constraint.
3. `test_search_is_tenant_scoped` — FK violation on
`users_tenant_id_fkey` when creating tenant B's admin. The `tenants`
table requires `domain text NOT NULL` (along with `name`), but
`ensure_tenant` only supplied `(id, name)`, so the insert silently
failed and tenant 999_001 never existed. Add the `domain` column.
Also replace the `let _ = ...` error-swallowing in both `ensure_tenant`
and `ensure_user_with_email` with `.expect(...)` so future fixture
problems fail loudly at the offending call site instead of cascading
into mysterious downstream FK errors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes the three CI failures from the post-merge deploy of #57. All three are bugs in the test file itself, not in production code. The new endpoint and repository helper are unaffected.
Failures and fixes
test_search_matches_substring_case_insensitive\"Joes Diner {uuid}\"and query\"joes {uuid[..8]}\"don't share a contiguous substring (\"Diner \"sits between them).\"JoesDiner-{uuid}\"so a single substring match works.test_search_aggregates_admin_emailsteam_users_user_pubkey_fkey. The unique constraint onusersis onpubkeyalone (users_pubkey_idx), not(pubkey, tenant_id), so theON CONFLICT (pubkey, tenant_id)inensure_user_with_emailwas a hard parse error thatlet _ = ...was silently swallowing.ON CONFLICT (pubkey) DO UPDATE.test_search_is_tenant_scopedusers_tenant_id_fkey. Thetenantstable requiresdomain text NOT NULL, butensure_tenantonly supplied(id, name), so the insert silently failed and tenant 999_001 never existed.domaincolumn to the insert.Also replaces the
let _ = ...error-swallowing in both fixture helpers with.expect(...)so future bugs fail loudly at the call site rather than cascading into mysterious downstream FK errors.Why this wasn't caught locally
I had no local Postgres available before pushing #57 — the new tests couldn't actually run. Compile-clean and clippy-clean, but the SQL bugs only surfaced once CI ran them against a live database. Lesson learned for future PRs touching repository tests.
Test plan
cargo fmt --all -- --checkcargo clippy -p keycast_api --tests --features integration-tests -- -D warningscargo check -p keycast_api --tests --features integration-tests🤖 Generated with Claude Code