Skip to content

test(selfhost): cover sqlite-to-postgres migration script (#8391) - #8405

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jsdevninja:test/migrate-selfhost-sqlite-pg-coverage
Jul 24, 2026
Merged

test(selfhost): cover sqlite-to-postgres migration script (#8391)#8405
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jsdevninja:test/migrate-selfhost-sqlite-pg-coverage

Conversation

@jsdevninja

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • npx vitest run test/unit/migrate-selfhost-sqlite-to-postgres.test.ts (15 tests)
  • npx tsc --noEmit
  • CI green on the PR

@jsdevninja
jsdevninja requested a review from JSONbored as a code owner July 24, 2026 11:44
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.17%. Comparing base (4a0b136) to head (8fbf902).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8405   +/-   ##
=======================================
  Coverage   92.17%   92.17%           
=======================================
  Files         791      791           
  Lines       79249    79249           
  Branches    23947    23945    -2     
=======================================
  Hits        73048    73048           
  Misses       5062     5062           
  Partials     1139     1139           
Flag Coverage Δ
shard-1 53.30% <ø> (-5.46%) ⬇️
shard-2 54.71% <ø> (+4.17%) ⬆️
shard-3 53.67% <ø> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-24 12:09:02 UTC

2 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds `export` to five already-existing functions/interfaces in the migration script (no behavior change) and adds a 495-line test suite exercising `quoteIdent`, `insertSql`, `valuePlaceholder`, `normalizePostgresValue`, `parseArgs`, and `copyAll` via a stateful mock PoolClient plus a real in-memory `node:sqlite` source. The tests exercise real branches (empty-target copy, vector include/exclude, missing target table, non-empty-target rejection, key-overlap merge/conflict, post-copy count validation, no-common-columns skip) against the actual SQL-shaping logic in `copyAll`, so this is genuine coverage of the real code paths rather than fabricated scenarios. It closes #8391 and is scoped narrowly to test-only additions plus the minimal export changes needed to reach the helpers.

Nits — 4 non-blocking
  • The mock `makeStatefulClient`'s `IS NOT DISTINCT FROM` branch (test/unit/migrate-selfhost-sqlite-to-postgres.test.ts:~90-105) infers key width from regex counting rather than being passed explicitly, which is fragile if the real query's OR-clause structure changes — a comment or explicit parameter would make this less brittle.
  • The large inline stateful-mock (~150 lines) duplicates logic already used elsewhere per the file's own comment referencing selfhost-pg-adapter.test.ts's convention; consider extracting a shared test helper if that pattern recurs a third time.
  • Consider factoring the repeated `makeStatefulClient`/`PgState` shape into a shared test util if another migration-adjacent script needs the same mock later.
  • The header comment in the test file (lines 1-4) is helpful; a short doc comment on `copyAll`'s exported signature in the script itself would aid future direct callers now that it's part of the public surface.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8391
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 215 registered-repo PR(s), 130 merged, 39 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jsdevninja; Gittensor profile; 215 PR(s), 39 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The PR adds test/unit/migrate-selfhost-sqlite-to-postgres.test.ts covering all listed pure helpers (quoteIdent, insertSql, valuePlaceholder, normalizePostgresValue, parseArgs) and copyAll's key decision branches (empty target happy path, vectors skip/include, missing target table, non-empty target rejection, allow-non-empty conflict/no-conflict, missing PK overlap, and post-copy exact vs at-least

Review context
  • Author: jsdevninja
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Swift, C, CSS, MDX, Python, TypeScript, Vue
  • Official Gittensor activity: 215 PR(s), 39 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 712836f into JSONbored:main Jul 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit test coverage for scripts/migrate-selfhost-sqlite-to-postgres.ts (zero tests for a high-stakes data migration)

1 participant