Fix code review findings: image read, whitespace validation, offset reset, cleanup error

- Replace src.Read(data) with io.ReadAll(src) to prevent silent truncation on large uploads
- Reject zero-byte file uploads with 400 rather than storing empty BYTEA
- Add strings.TrimSpace to validateFruit so whitespace-only name/osdb_number returns 422
- Reset offset to 0 in fruitStore.create() so navigating back to list after create shows page 1
- Log t.Cleanup DELETE error in integration test to surface constraint failures clearly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 10:28:51 +02:00
co-authored by Claude Sonnet 4.6
parent 1b889ac112
commit 841f53fac8
3 changed files with 14 additions and 5 deletions
@@ -41,7 +41,9 @@ func TestFruitRepoIntegration(t *testing.T) {
// cleanup after test
t.Cleanup(func() {
pool.Exec(ctx, `DELETE FROM fruits WHERE osdb_number LIKE 'TEST-%'`)
if _, err := pool.Exec(ctx, `DELETE FROM fruits WHERE osdb_number LIKE 'TEST-%'`); err != nil {
t.Logf("cleanup: %v", err)
}
})
// Create