Skip to content

P1: Increase test coverage to 80% #67

@BadgerOps

Description

@BadgerOps

Test Coverage Below Target

Priority: P1 - High
Estimate: 6 hours
Review Reference: REVIEW.md (P1-6)

Current State

  • Overall: 52.5%
  • internal/http: 51.6%
  • internal/storage: 72.2%
  • Target: 80%

Missing Test Scenarios

  1. Error paths in HTTP handlers - Many error branches untested
  2. Pagination edge cases - Offset/limit boundary conditions
  3. CIDR computation edge cases - /31, /32 prefixes
  4. Export functionality - CSV generation, field filtering
  5. Migration rollback scenarios
  6. Concurrent access patterns

Solution

Add comprehensive test files:

  • internal/http/handlers_error_test.go - Error scenarios
  • Pagination boundary tests
  • CIDR edge case tests (/31, /32 handling)
  • CSV export with various field combinations
  • Concurrent pool operation tests

Example Missing Tests:

func TestPoolsHandlers_StorageErrors(t *testing.T) {
    // Use mock store that returns errors
    // Test each handler's error path
}

func TestBlocks_EdgeCases(t *testing.T) {
    // Test /31 and /32 prefix handling
    // Test huge pagination requests
    // Test negative offsets
}

func TestExport_AllFormats(t *testing.T) {
    // Test CSV field selection
    // Test empty datasets
    // Test large datasets (memory usage)
}

Acceptance Criteria

  • Overall coverage >= 80%
  • All error paths in handlers tested
  • Pagination edge cases covered
  • CIDR /31 and /32 tests added
  • CSV export comprehensively tested
  • Concurrent access tests added
  • Coverage report generated and checked in CI

Validation

make cover
# Check coverage.html - should show 80%+ overall
make test-race
# Verify no race conditions in new tests

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions