Skip to content

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

Description

@iroiro147

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions