test: add test coverage for DB, file handlers, CSV/ODS, and API endpoints #86

Merged
forbes merged 4 commits from test-coverage-batch into main 2026-02-14 14:50:39 +00:00
Owner

Resolves #75, #76, #77, #78.

Summary

51 new test functions across 9 new files, 0 production code changes.

#75 — DB edge-case tests

  • internal/db/items_edge_test.go (10 tests): duplicate part number, hard delete, pagination, search, revision status/labels/compare/rollback, project-item associations
  • internal/db/item_files_test.go (4 tests): file CRUD operations

#76 — File handler tests

  • internal/api/file_handlers_test.go (8 tests): list/delete files via DB, cross-item guard, storage-unavailable error paths (presign, upload, associate, thumbnail)

#77 — CSV/ODS handler tests

  • internal/api/csv_handlers_test.go (6 tests): export empty/with items, template, import dry-run/commit, BOM CSV export
  • internal/api/ods_handlers_test.go (3 tests): export, template, project sheet

#78 — API endpoint tests

  • internal/api/revision_handlers_test.go (8 tests): list, get, create, update, compare, rollback, not-found paths
  • internal/api/schema_handlers_test.go (4 tests): list, get, form descriptor, not-found
  • internal/api/audit_handlers_test.go (4 tests): completeness summary/detail, not-found
  • internal/api/auth_handlers_test.go (4 tests): current user, auth config, token lifecycle

Bug fix

  • Fixed createItemDirect helper: StandardCost field was removed from Item struct, now passes cost as revision property instead
Resolves #75, #76, #77, #78. ## Summary 51 new test functions across 9 new files, 0 production code changes. ### #75 — DB edge-case tests - `internal/db/items_edge_test.go` (10 tests): duplicate part number, hard delete, pagination, search, revision status/labels/compare/rollback, project-item associations - `internal/db/item_files_test.go` (4 tests): file CRUD operations ### #76 — File handler tests - `internal/api/file_handlers_test.go` (8 tests): list/delete files via DB, cross-item guard, storage-unavailable error paths (presign, upload, associate, thumbnail) ### #77 — CSV/ODS handler tests - `internal/api/csv_handlers_test.go` (6 tests): export empty/with items, template, import dry-run/commit, BOM CSV export - `internal/api/ods_handlers_test.go` (3 tests): export, template, project sheet ### #78 — API endpoint tests - `internal/api/revision_handlers_test.go` (8 tests): list, get, create, update, compare, rollback, not-found paths - `internal/api/schema_handlers_test.go` (4 tests): list, get, form descriptor, not-found - `internal/api/audit_handlers_test.go` (4 tests): completeness summary/detail, not-found - `internal/api/auth_handlers_test.go` (4 tests): current user, auth config, token lifecycle ### Bug fix - Fixed `createItemDirect` helper: `StandardCost` field was removed from `Item` struct, now passes cost as revision property instead
forbes added 4 commits 2026-02-13 21:23:06 +00:00
- Duplicate part number constraint (PG 23505)
- Hard delete, pagination, search filtering
- Revision status/labels update, compare, rollback
- Project-item association by code, list by project filter
- Item file CRUD: create, list, get, delete
- Test ListItemFiles, DeleteItemFile with real DB
- Test cross-item file deletion guard (404)
- Test storage-unavailable paths: presign, upload, associate, thumbnail (503)
- Fix createItemDirect: StandardCost moved to revision properties
CSV tests:
- Export empty/with items, template generation
- Import dry-run (preview without creating), commit (items created)
- BOM CSV export with parent/child relationships

ODS tests:
- Export with items (verify ODS content type and ZIP magic bytes)
- Template generation per schema
- Project sheet export with item associations
Revision tests (8):
- List, get, create, update status/labels, compare, rollback
- Not-found paths for missing items and revisions

Schema tests (4):
- List schemas, get by name, form descriptor, not-found

Audit tests (4):
- Completeness summary (empty + with items), item detail, not-found

Auth tests (4):
- Get current user (authenticated + unauthenticated)
- Auth config response
- Token lifecycle: create, list, revoke
forbes merged commit 376fa3db31 into main 2026-02-14 14:50:39 +00:00
forbes deleted branch test-coverage-batch 2026-02-14 14:50:40 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#86