Skip to content

Add internal/repository tests#746

Merged
vfusco merged 10 commits intonext/2.0from
feature/repository-tests
Mar 2, 2026
Merged

Add internal/repository tests#746
vfusco merged 10 commits intonext/2.0from
feature/repository-tests

Conversation

@vfusco
Copy link
Collaborator

@vfusco vfusco commented Mar 2, 2026

No description provided.

@vfusco vfusco added this to the 2.0.0 milestone Mar 2, 2026
@vfusco vfusco self-assigned this Mar 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a backend-agnostic repository test suite (run against the Postgres implementation) and refactors parts of the Postgres repository layer for consistency and improved transactional behavior, alongside a small service lifecycle tweak and optional Go test coverage reporting.

Changes:

  • Introduces internal/repository/repotest suites + Postgres harness to exercise repository behavior end-to-end.
  • Refactors Postgres repository methods to use consistent uint64 SQL expressions, consistent sentinel errors (repository.ErrNotFound / repository.ErrNoUpdate), and improved transaction handling (including row-iteration rows.Err() checks).
  • Improves node/service creation error handling (avoid os.Exit) and adds an optional Makefile coverage workflow.

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/service/service.go Avoids calling the first tick if the service context is already canceled.
internal/validator/validator_test.go Trims whitespace in tests (no behavior change).
internal/repository/repotest/repotest.go Adds shared repository test harness with per-subtest repo isolation.
internal/repository/repotest/builders.go Adds builders + seeding helpers for repository integration tests.
internal/repository/repotest/application_test_cases.go Adds application repository test coverage.
internal/repository/repotest/epoch_test_cases.go Adds epoch repository test coverage.
internal/repository/repotest/input_test_cases.go Adds input repository test coverage.
internal/repository/repotest/output_test_cases.go Adds output repository test coverage (including transactional update assertions).
internal/repository/repotest/report_test_cases.go Adds report repository test coverage.
internal/repository/repotest/state_hash_test_cases.go Adds state-hash repository test coverage.
internal/repository/repotest/node_config_test_cases.go Adds node-config repository test coverage.
internal/repository/repotest/claimer_test_cases.go Adds claimer query/update repository test coverage.
internal/repository/repotest/commitment_test_cases.go Adds commitment repository test coverage.
internal/repository/repotest/match_test_cases.go Adds match repository test coverage.
internal/repository/repotest/match_advanced_test_cases.go Adds match-advanced repository test coverage.
internal/repository/repotest/tournament_test_cases.go Adds tournament repository test coverage.
internal/repository/repository.go Introduces consistent sentinel errors (ErrNotFound, ErrNoUpdate) and minor parameter naming cleanup.
internal/repository/postgres/util.go Simplifies application lookup predicate building and adds uint64Expr helper.
internal/repository/postgres/application.go Adopts uint64Expr, adds rows.Err() checks, and aligns “not found” behavior for updates.
internal/repository/postgres/epoch.go Uses uint64Expr, improves transaction rollback/commit patterns, adds batching for input inserts, and adds rows.Err() checks.
internal/repository/postgres/input.go Uses uint64Expr and adds rows.Err() checks.
internal/repository/postgres/output.go Uses uint64Expr, improves transaction handling, and adds rows.Err() checks.
internal/repository/postgres/report.go Uses uint64Expr and adds rows.Err() checks.
internal/repository/postgres/state_hash.go Uses uint64Expr and adds rows.Err() checks.
internal/repository/postgres/tournament.go Uses uint64Expr, adds rows.Err() checks, and aligns “not found” error.
internal/repository/postgres/commitment.go Uses uint64Expr and adds rows.Err() checks.
internal/repository/postgres/match.go Uses uint64Expr, adds rows.Err() checks, and aligns “not found” error.
internal/repository/postgres/match_advanced.go Uses uint64Expr and adds rows.Err() checks.
internal/repository/postgres/claimer.go Runs read queries inside a transaction snapshot and uses repository.ErrNoUpdate for no-op updates.
internal/repository/postgres/bulk.go Uses uint64Expr, improves transaction handling, and introduces batching for some updates.
internal/repository/postgres/repository.go Makes retry sleeps context-aware to prevent long hangs on shutdown/cancel.
internal/repository/postgres/repository_error_test.go Adds coverage for Postgres repository construction failure modes.
internal/repository/postgres/postgres_repo_test.go Adds an integration harness that runs all repotest suites against Postgres.
internal/repository/factory/factory.go Improves error messaging for unsupported connection string schemes.
internal/node/node.go Refactors child service creation to return errors instead of exiting the process.
internal/claimer/claimer.go Renames parameters to match repository interface changes.
Makefile Adds optional coverage output generation and cleans coverage artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vfusco vfusco force-pushed the feature/repository-tests branch from 6d14d93 to 847f21d Compare March 2, 2026 16:22
renatomaia
renatomaia previously approved these changes Mar 2, 2026
@github-project-automation github-project-automation bot moved this from Todo to Waiting Merge in Rollups SDK Mar 2, 2026
@vfusco vfusco force-pushed the feature/repository-tests branch from 847f21d to 0c869cb Compare March 2, 2026 20:46
@vfusco vfusco force-pushed the feature/repository-tests branch from 0c869cb to e865eec Compare March 2, 2026 20:54
renatomaia
renatomaia previously approved these changes Mar 2, 2026
@vfusco vfusco merged commit c690c8c into next/2.0 Mar 2, 2026
6 checks passed
@vfusco vfusco deleted the feature/repository-tests branch March 2, 2026 23:39
@github-project-automation github-project-automation bot moved this from Waiting Merge to Done in Rollups SDK Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants