block / block/buzz

test(relay): skip 2 PG-dependent admin report/feedback 404 tests when BUZZ_TEST_DATABASE_URL unset

Open Beginner friendly
#4,083 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

## Summary

`crates/buzz-relay/src/api/admin/mod.rs` has two PG-dependent integration tests in `mod tests` that fail hard when run without a live Postgres, mirroring the exact problem tracked in #4080 for `api::media::tests`:

- `admin::tests::report_detail_rejects_unknown_report` — calls `test_state()` (which eagerly seeds a community via `ensure_configured_community`, panicking if `BUZZ_DATABASE_URL` is unset), then asserts a 404 for `/reports/{nil-uuid}` on the admin host.
- `admin::tests::feedback_attachment_rejects_unknown_feedback` — same shape, asserts 404 for `/feedback/{nil-uuid}/attachments/{hash}`.

Both currently fail with a 500 (from a dead `PoolTimedOut` / connect error surfaced as `S3Error`-style 500, not the application-level `ApiError::not_found`) whenever `cargo test -p buzz-relay` runs in an environment where `BUZZ_TEST_DATABASE_URL` is not pointing at a live Postgres.

Sibling tests in the same module that assert 403 (admin-host gate, before any DB access) continue to pass — these two are the only ones post-`authorize` DB call.

## Proposed fix

Apply the same `#[ignore = "requires a live Postgres: set BUZZ_TEST_DATABASE_URL"]` attribute pattern used in `crates/buzz-search/tests/fts_integration.rs` and already applied to `api::media::tests` for #4080. Then `cargo test -p buzz-relay` passes cleanly in PG-less environments and developers opt back into the live-Postgres surface with:

```sh
BUZZ_TEST_DATABASE_URL=postgres://buzz:buzz_dev@localhost:5432/buzz \
cargo test -p buzz-relay -- --include-ignored
```

## Follow-up (out of scope)

Refactoring `test_state()` to stop eagerly seeding a community (the same DX problem called out in #4080) would let even more admin tests run without PG.

Contributor guide

Open the contributing guide

Research direction

Open crates/buzz-relay/src/api/admin/mod.rs and locate admin::tests::report_detail_rejects_unknown_report and admin::tests::feedback_attachment_rejects_unknown_feedback. Compare their test attributes with the pattern in crates/buzz-search/tests/fts_integration.rs and the media tests from #4080. Run cargo test -p buzz-relay without Postgres, then confirm the suite passes and both tests run with -- --include-ignored when BUZZ_TEST_DATABASE_URL is set.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.