Skip to content

test(fetchers): add live integration tests behind feature flag#84

Merged
chaliy merged 2 commits intomainfrom
claude/add-fetcher-integration-tests-A7vId
Mar 27, 2026
Merged

test(fetchers): add live integration tests behind feature flag#84
chaliy merged 2 commits intomainfrom
claude/add-fetcher-integration-tests-A7vId

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 27, 2026

What

Adds live integration tests that hit real endpoints for all 13 fetchers, gated behind a live-tests cargo feature flag. Includes a CI job that selectively runs only the tests for fetchers whose source files changed.

Why

Existing tests use wiremock exclusively — good for reliability but no validation that fetchers produce correct output against live sites. If an upstream API changes (GitHub HTML layout, Twitter API shift), we wouldn't know until someone runs examples manually.

How

  • Feature flag: live-tests in crates/fetchkit/Cargo.toml — tests don't compile without it, so cargo test is unaffected
  • Test file: tests/fetcher_live.rs with one module per fetcher (live_github_repo, live_twitter, etc.), using structural assertions (non-empty content, expected substrings)
  • Network resilience: fetch_or_skip() helper treats DNS/timeout/blocked errors as skips, not failures — live tests only fail on unexpected response structure
  • CI job: live-tests in ci.yml runs on PRs only, uses scripts/changed-fetcher-tests.sh to detect changed fetcher files and map them to test filters. continue-on-error: true so flaky endpoints don't block merges
  • Detection script: scripts/changed-fetcher-tests.sh diffs against base branch, maps fetchers/<name>.rslive_<name> test filter

Usage:

cargo test --features live-tests                    # all live tests
cargo test --features live-tests live_github_repo   # single fetcher

Risk

  • Low
  • Test-only change, no production code modified
  • Live tests are non-blocking in CI (continue-on-error: true)

Checklist

  • Unit tests are passed
  • Smoke tests are passed
  • Live tests compile and run (15/15 pass; network-unavailable endpoints gracefully skip)
  • Specs are up to date and not in conflict

chaliy added 2 commits March 27, 2026 21:51
Adds `live-tests` feature flag with tests hitting real endpoints for all
13 fetchers. Tests assert structural properties (non-empty, expected
substrings) rather than exact content. CI job detects changed fetcher
files and runs only the relevant live tests (continue-on-error: true).

- `cargo test --features live-tests` runs all live tests
- `cargo test --features live-tests live_github_repo` runs one fetcher
- Normal `cargo test` is unaffected (tests don't compile without flag)
…ertions

Live tests now skip (not fail) when network is unavailable — DNS
resolution failures, timeouts, and blocked URLs are treated as
infra issues. Twitter test accepts any status code since the API
is notoriously unreliable.
@chaliy chaliy merged commit f795d02 into main Mar 27, 2026
11 checks passed
@chaliy chaliy deleted the claude/add-fetcher-integration-tests-A7vId branch March 27, 2026 21:57
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