block / block/buzz

test(relay): skip 7 PG-dependent media tests when BUZZ_TEST_DATABASE_URL unset

Open Beginner friendly
#4,080 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

## Problem

`cargo test -p buzz-relay` on a contributor machine without a local Postgres reports **10 failures**, 7 of which are `pool timed out while waiting for an open connection` errors in `crates/buzz-relay/src/api/media.rs::tests`. They are not real regressions; the tests need Postgres but are marked as plain `#[tokio::test]`, so they run unconditionally.

The repo already has the established `#[ignore = "requires a live Postgres: set BUZZ_TEST_DATABASE_URL"]` pattern in `crates/buzz-search/tests/fts_integration.rs`, where live-PG tests are excluded from the default `cargo test` run but re-enabled via `cargo test -- --include-ignored` plus `BUZZ_TEST_DATABASE_URL=postgres://…`.

This makes the default developer loop produce a wall of "failures" that are really environmental — new contributors can't tell whether they broke something, and CI/suite signal gets diluted.

## Failing tests (all `crates/buzz-relay/src/api/media.rs::tests`)

- `media_get_auth_flag_on_accepts_range_header_only_after_auth`
- `media_get_auth_flag_on_rejects_unauthenticated_get_and_head_before_sidecar_gate`
- `media_get_auth_flag_on_rejects_upload_verb_wrong_server_and_wrong_x`
- `media_get_auth_flag_on_valid_server_scoped_token_reaches_sidecar_gate`
- `media_get_auth_flag_off_allows_unauthenticated_read_until_sidecar_gate`
- `upload_concurrency_limit_is_scoped_by_community`
- `upload_rate_limiter_is scoped_by_community`

## Proposed fix

Apply the same `#[ignore]` annotation so `cargo test -p buzz-relay` reports `0 failed; 42 ignored` on a clean checkout (up from `0 ignored` today). Tests remain runnable via `cargo test -p buzz-relay -- --include-ignored` when `BUZZ_TEST_DATABASE_URL` is set.

Out of scope in this issue:

- The 2 remaining pre-existing fails (`api::admin::tests::feedback_attachment_rejects_unknown_feedback` and `api::admin::tests::report_detail_rejects_unknown_report`) — separate semantic-drift problem tracked separately.
- Refactoring `test_state()` to not eagerly seed `relay.example` — a decoupling worth doing later so the upload-community-scope tests can run without PG at all. This `#[ignore]` change intentionally makes the *minimum* delta.

## Verification (after patch on a machine without PG running)

```
cargo test -p buzz-relay --lib --no-fail-fast
# → 826 passed; 2 failed; 42 ignored (the 2 admin fails are pre-existing)
# vs today's
# → 824 passed; 9 failed; 0 ignored
cargo test -p buzz-relay api::media -- --include-ignored
# → 7 media tests run and fail with PoolTimedOut, as expected when PG is down
```

Contributor guide

Open the contributing guide

Research direction

Open crates/buzz-relay/src/api/media.rs and locate the seven named tests in its tests module; compare their annotations with crates/buzz-search/tests/fts_integration.rs. Apply the established ignored-test pattern, then run cargo test -p buzz-relay --lib --no-fail-fast without Postgres and confirm the seven media tests are ignored while the two noted admin failures remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, rust
Domain
databases, testing
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.