generated from CubeCraft-Creations/Tracehound
CUB-235: Add tests for GET /api/v1/cameras/:id with 24h history #9
Reference in New Issue
Block a user
Delete Branch "agent/dex/CUB-235-camera-detail"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CUB-235: Implement GET /api/v1/cameras/:id with 24h history
Implementation Confirmed
The
GetCameraDetailhandler already exists ondevand implements:{ camera, last_status, history }r.Get("/cameras/{id}", api.GetCameraDetail(database))Tests Added (6 test cases)
TestGetCameraDetail_NotFound: 404 for missing cameraTestGetCameraDetail_Success: 200 with camera + last_status + historyTestGetCameraDetail_EmptyHistory: camera with no status logs returns empty arrayTestGetCameraDetail_HistoryLimitedTo100: history capped at 100 entriesTestGetCameraDetail_MissingID: 400 for empty ID paramTestGetCameraDetail_LastStatusPresent: verifies last_status field populatedBug Found
mac_addresscolumn is nullable butCamera.MacAddressisstring— NULL scan crashes with error. Tests work around by providing mac_address in seed data. This should be fixed separately (use*stringorsql.NullString).Validation
go build ./internal/api/...→ PASSgo vet ./internal/api/...→ PASSgo test ./internal/api/...→ 6/6 PASSPull request closed