Commit Graph
2 Commits
Author SHA1 Message Date
john-okeefe 00a083b60b Rename backend code references: Bookmann → Bookhoard
Backend changes:
- Update import paths: bookmann/internal → bookhoard/internal
- Rename struct fields: BookmannUUID → BookhoardUUID
- Update handler function names: mapContentIdToBookmannUUID → mapContentIdToBookhoardUUID
- Update HTTP response headers: X-Bookmann-* → X-Bookhoard-*
- Update service and middleware references
- Update main.go imports and references

This is part 2 of the project rename to Bookhoard.
2026-02-01 16:11:54 -05:00
john-okeefe 6e843c93d0 test(collections): add comprehensive rule evaluation test suite
Add extensive unit tests for collection rule matching logic:

Test Coverage (30+ tests):
1. Rule Evaluation Tests:
   - Equals operator (match and no match)
   - Not equals operator (match and no match)
   - Contains operator (case-insensitive)
   - Not contains operator
   - Starts with operator
   - Ends with operator
   - Greater than operator (numeric)
   - Less than operator (numeric)
   - NULL field handling

2. Comparison Function Tests:
   - Case-insensitive string matching
   - Empty string edge cases
   - Numeric edge cases (0, negative, large numbers)
   - Type conversion validation

3. Multi-Rule Tests:
   - Matches first rule
   - Matches second rule (first fails)
   - No matches across all rules
   - Empty rules array

4. Complex Rule Scenarios:
   - Multiple conditions on same book
   - Different field types (genre, author, year, series)
   - Various operators tested
   - Table-driven test for 8 scenarios

5. Edge Cases and Error Handling:
   - Invalid operator returns false
   - Non-existent field returns false
   - Invalid numeric strings handled
   - Type conversion failures

Test Structure:
- Clear test names explaining what's being tested
- Assertion messages explain expected vs actual
- Uses testify/assert for better error messages
- Table-driven tests for multiple scenarios
- Comprehensive edge case coverage

Code Coverage:
- evaluateRule() function
- compareValues() function
- checkRulesAgainstBook() function
- All operators: equals, not_equals, contains, not_contains,
  starts_with, ends_with, greater_than, less_than
- All field types: genre, author, series, copyright_year

Test Results:
- All 30+ tests passing
- Coverage of critical collection rule logic
- Prevents regressions in rule matching
- Validates edge case handling

This test suite ensures the collection auto-assignment
feature works correctly for all supported rule types and operators.
2026-02-01 01:02:42 -05:00