- 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>
32 lines
765 B
Go
32 lines
765 B
Go
package database
|
|
|
|
import "sort"
|
|
|
|
// sortMigrationNames returns a sorted copy of the names slice.
|
|
func sortMigrationNames(names []string) []string {
|
|
sorted := make([]string, len(names))
|
|
copy(sorted, names)
|
|
sort.Strings(sorted)
|
|
return sorted
|
|
}
|
|
|
|
// buildAppliedSet converts a list of applied migrations to a lookup set.
|
|
func buildAppliedSet(applied []DataMigration) map[string]bool {
|
|
set := make(map[string]bool, len(applied))
|
|
for _, m := range applied {
|
|
set[m.Name] = true
|
|
}
|
|
return set
|
|
}
|
|
|
|
// filterPending returns names not present in the applied set.
|
|
func filterPending(names []string, applied map[string]bool) []string {
|
|
var pending []string
|
|
for _, name := range names {
|
|
if !applied[name] {
|
|
pending = append(pending, name)
|
|
}
|
|
}
|
|
return pending
|
|
}
|