Coverage priorities 1-5: test pure functions, extract interfaces, mock-based handler tests

- Priority 1: Test NewSendEmailTask + NewSendPushTask (5 tests)
- Priority 2: Test customHTTPErrorHandler — all 15+ branches (21 tests)
- Priority 3: Extract Enqueuer interface + payload builders in worker pkg (5 tests)
- Priority 4: Extract ClassifyFile/ComputeRelPath in migrate-encrypt (6 tests)
- Priority 5: Define Handler interfaces, refactor to accept them, mock-based tests (14 tests)
- Fix .gitignore: /worker instead of worker to stop ignoring internal/worker/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey T
2026-04-01 20:30:09 -05:00
parent 00fd674b56
commit bec880886b
83 changed files with 19569 additions and 730 deletions

View File

@@ -0,0 +1,39 @@
package jobs
import (
"fmt"
"strings"
"github.com/treytartt/honeydue-api/internal/models"
)
// BuildDigestMessage constructs the daily digest notification text.
func BuildDigestMessage(overdueCount, dueThisWeekCount int) (title, body string) {
title = "Daily Task Summary"
if overdueCount > 0 && dueThisWeekCount > 0 {
body = fmt.Sprintf("You have %d overdue task(s) and %d task(s) due this week", overdueCount, dueThisWeekCount)
} else if overdueCount > 0 {
body = fmt.Sprintf("You have %d overdue task(s) that need attention", overdueCount)
} else {
body = fmt.Sprintf("You have %d task(s) due this week", dueThisWeekCount)
}
return
}
// IsOverdueStage checks if a reminder stage string represents overdue.
func IsOverdueStage(stage string) bool {
return strings.HasPrefix(stage, "overdue")
}
// ExtractFrequencyDays gets interval days from a task's frequency.
func ExtractFrequencyDays(t *models.Task) *int {
if t.Frequency != nil && t.Frequency.Days != nil {
days := *t.Frequency.Days
return &days
}
if t.CustomIntervalDays != nil {
days := *t.CustomIntervalDays
return &days
}
return nil
}