- HeartbeatArgs + HeartbeatWorker (logs slog.Info on each tick) - OrphanCleanupArgs + OrphanCleanupWorker (S3 delete then DB delete loop) - NewOrphanCleanupWorker constructor with pool + FileStorer injection - SlogErrorHandler implementing river.ErrorHandler (HandleError + HandlePanic) - fileQuerier interface for test injection without real DB - Unit tests: 7 tests pass (pure mock-based, no DB required) - go build ./... exits 0
35 lines
759 B
Go
35 lines
759 B
Go
package jobs
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/riverqueue/river/rivertype"
|
|
)
|
|
|
|
func TestSlogErrorHandler_HandleError(t *testing.T) {
|
|
h := &SlogErrorHandler{}
|
|
job := &rivertype.JobRow{
|
|
ID: 1,
|
|
Kind: "test_job",
|
|
Attempt: 1,
|
|
MaxAttempts: 3,
|
|
}
|
|
result := h.HandleError(context.Background(), job, errors.New("test error"))
|
|
if result != nil {
|
|
t.Errorf("HandleError returned %v, want nil", result)
|
|
}
|
|
}
|
|
|
|
func TestSlogErrorHandler_HandlePanic(t *testing.T) {
|
|
h := &SlogErrorHandler{}
|
|
job := &rivertype.JobRow{
|
|
ID: 2,
|
|
Kind: "test_job",
|
|
}
|
|
result := h.HandlePanic(context.Background(), job, "panic value", "goroutine 1 ...")
|
|
if result != nil {
|
|
t.Errorf("HandlePanic returned %v, want nil", result)
|
|
}
|
|
}
|