test: add coverage for CSV import route - #288
Open
Spaceben123 wants to merge 1 commit into
Open
Conversation
Covers importTableFromCsvRoute (src/import/csv.ts), which previously had no dedicated test file: unsupported content-type, empty body, missing multipart file, empty/header-only CSV, raw text/csv and JSON-wrapped CSV ingestion, column mapping, malformed rows being skipped, partial insert failures, and malformed JSON payloads. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MQvd9avZenwbcumQHWuusX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim #71
What
src/import/csv.ts(thetext/csv, JSON-wrapped, and multipart CSV import route) was the one import module without a dedicated test file —json.test.tsanddump.test.tsalready existed for its siblings,csv.test.tsdid not.Adds
src/import/csv.test.ts, following the existing mocking pattern fromjson.test.ts(mocksexecuteOperationandcreateResponse), covering:Content-Typemultipart/form-datatext/csvbodycolumnMappingmultipart/form-datafile uploadparseCSVworth locking in)Content-Type: application/jsonis set but the body isn't valid JSONDemo
No screen-recording tool available in this environment, so here's the actual
vitestrun instead of a video:```
$ pnpm exec vitest run src/import/csv.test.ts
✓ src/import/csv.test.ts (12 tests) 17ms
Test Files 1 passed (1)
Tests 12 passed (12)
```
Full suite (
pnpm exec vitest run) is unaffected: 163 passed both before and after this change, plus the 12 new ones. The 4 pre-existing failures insrc/rls/index.test.tsare unrelated to this change (multi-table/subquery RLS SQL-rewriting assertions) and are present onmainwithout this PR.This PR was written with AI assistance (Claude Code) and verified by running the actual test suite locally — happy to adjust naming/style or add cases if anything's off.