Skip to content

test: add GitHub collector fixture replay#17

Merged
ginsengcandy merged 1 commit into
mainfrom
test/9-github-fixture-replay
May 30, 2026
Merged

test: add GitHub collector fixture replay#17
ginsengcandy merged 1 commit into
mainfrom
test/9-github-fixture-replay

Conversation

@ginsengcandy
Copy link
Copy Markdown
Owner

@ginsengcandy ginsengcandy commented May 30, 2026

Summary

  • add a GitHub Search API JSON fixture under test resources
  • add a replay test that verifies GitHub repository normalization into CollectedItem without live API calls
  • cover canonical URL duplicate skipping when the same fixture is replayed
  • isolate repository-backed Spring Boot tests from shared H2 context state
  • record TD-017 and TR-006 for the replay harness decision and test data cleanup issue

Tests

  • ./gradlew test

Closes #9

Summary by CodeRabbit

  • Documentation

    • Added technical decision record documenting GitHub collection pipeline testing approach using fixture-based tests.
    • Added troubleshooting guide entry documenting a data integrity issue encountered during testing and its resolution.
  • Tests

    • Added comprehensive test suite validating GitHub search collection with fixture replay.
    • Improved test isolation by implementing cleanup logic to prevent test data conflicts.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c9aeb5e-9d17-410b-9ecd-81dcbcbe9dac

📥 Commits

Reviewing files that changed from the base of the PR and between 7a30cf3 and 8801080.

📒 Files selected for processing (5)
  • docs/technical-decisions.md
  • docs/troubleshooting.md
  • src/test/java/com/questack/collection/github/service/GithubCollectorReplayTest.java
  • src/test/java/com/questack/ranking/service/RankingServiceTest.java
  • src/test/resources/fixtures/github/search-repositories.json

📝 Walkthrough

Walkthrough

This PR introduces fixture-based replay testing for GitHub collection, enabling offline verification of normalization, source creation, and duplicate detection without live API calls. It includes a JSON fixture with sample repositories, a comprehensive test suite validating both first-run collection and duplicate detection on replay, test isolation improvements to prevent cross-test contamination, and documentation of the technical approach and lessons learned.

Changes

GitHub Fixture Replay Test Suite

Layer / File(s) Summary
GitHub Search fixture data
src/test/resources/fixtures/github/search-repositories.json
JSON response fixture with two sample repositories including IDs, URLs, descriptions, stars, languages, timestamps, and owner metadata.
GitHub collector replay test implementation
src/test/java/com/questack/collection/github/service/GithubCollectorReplayTest.java
Test class mocking GithubSearchClient to return fixture items; first test verifies replay normalizes and persists Source and CollectedItem entities with expected fields; second test confirms duplicate detection by canonical URL on second replay, with zero new saves and correct skip count.
Test isolation and cleanup setup
src/test/java/com/questack/ranking/service/RankingServiceTest.java
Adds @BeforeEach cleanup hook clearing RankingScoreRepository, CollectedItemRepository, and SourceRepository before each test, preventing H2 unique constraint violations from data reuse across tests in the same application context.
Technical decisions and troubleshooting logs
docs/technical-decisions.md, docs/troubleshooting.md
Documents fixture replay testing approach including verification scope and file paths; records unique constraint issue encountered during test integration, root cause (shared application context and DB state), and resolution (ordered cleanup by foreign key dependencies).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • ginsengcandy/Questack#1: Introduced RankingServiceTest and ranking API/service that now requires the added cleanup logic to prevent H2 unique constraint violations when tests share application context.

Poem

🐰 A fixture arrives, no API calls to make,
GitHub repos replay, for testing's own sake,
Duplicates found by their canonical way,
Clean isolation ensures tests don't stray,
Lessons recorded, solutions laid plain. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding fixture-based replay testing for GitHub collection without live API calls.
Linked Issues check ✅ Passed All coding objectives from issue #9 are met: fixture payloads saved, replay tests with normalization verification added, duplicate prevention by canonical URL covered, and external/internal DTOs kept separate.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue objectives: fixture file, replay test, test cleanup isolation, and documentation of decisions and troubleshooting are all in scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/9-github-fixture-replay

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ginsengcandy ginsengcandy merged commit 3544046 into main May 30, 2026
1 check passed
@ginsengcandy ginsengcandy deleted the test/9-github-fixture-replay branch May 30, 2026 13:16
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.

Add fixture replay tests for GitHub collection

1 participant