refactor(tests): enhance test infrastructure with library/collection helpers

- Add LibraryTestData struct to TestDeviceSetup
- Implement CreateLibrary() for proper library creation in tests
- Implement CreateCollection() for test collection support
- Improve test isolation with dedicated library creation

This provides a more robust foundation for integration tests that need
proper library management support.
This commit is contained in:
2026-02-13 20:04:47 -05:00
parent 8ed0bdb040
commit 368c790c67
11 changed files with 849 additions and 556 deletions
+27 -14
View File
@@ -1,20 +1,33 @@
package handlers
import (
"bookhoard/internal/database"
)
// SearchHandler handles search, query, and filtered operations
type SearchHandler struct {
db *database.Queries
// SearchBookResponse represents a single book in search results
type SearchBookResponse struct {
ID string `json:"id"`
Title string `json:"title"`
Authors []SearchAuthor `json:"authors"`
}
// NewSearchHandler creates a new search handler
func NewSearchHandler(db *database.Queries) *SearchHandler {
return &SearchHandler{
db: db,
}
// SearchAuthor represents an author in search results
type SearchAuthor struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
// Note: SearchMediaItems was moved to MediaHandler in Phase 2
// The SearchHandler is reserved for future search-specific operations
// SearchResponse represents the complete search response
type SearchResponse struct {
Results []SearchBookResponse `json:"results"`
Total int `json:"total"`
}
// SearchMediaItemsResponse represents search response with media items
type SearchMediaItemsResponse struct {
Results []MediaItemSummary `json:"results"`
Total int `json:"total"`
}
// MediaItemSummary represents a single media item in search results
type MediaItemSummary struct {
ID string `json:"id"`
Title string `json:"title"`
Authors []SearchAuthor `json:"authors"`
}
-1
View File
@@ -39,7 +39,6 @@ type Config struct {
LibraryHandler *handlers.LibraryHandler
DeviceHandler *handlers.DeviceHandler
MediaHandler *handlers.MediaHandler
SearchHandler *handlers.SearchHandler
MatchingHandler *handlers.MatchingHandler
KOReaderHandler *handlers.KOReaderHandler
WSHandler *handlers.WSHandler