Record generation outcomes and summaries for history while keeping article content transient. Refs #7 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
885 B
Go
36 lines
885 B
Go
package scheduler
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/tradarr/backend/internal/generation"
|
|
"github.com/tradarr/backend/internal/models"
|
|
)
|
|
|
|
type scheduledUsers struct{}
|
|
|
|
func (scheduledUsers) ListUsers() ([]models.User, error) {
|
|
return []models.User{{ID: "alpha"}, {ID: "beta"}}, nil
|
|
}
|
|
|
|
type scheduledGenerator struct{ ids []string }
|
|
|
|
func (g *scheduledGenerator) Generate(_ context.Context, id string) (generation.Result, error) {
|
|
g.ids = append(g.ids, id)
|
|
if id == "alpha" {
|
|
return generation.Result{}, errors.New("failure")
|
|
}
|
|
return generation.Result{}, nil
|
|
}
|
|
func TestScheduledGenerationContinuesIndependentlyPerUser(t *testing.T) {
|
|
g := &scheduledGenerator{}
|
|
s := &Scheduler{users: scheduledUsers{}, generationUseCase: g}
|
|
s.run()
|
|
if !reflect.DeepEqual(g.ids, []string{"alpha", "beta"}) {
|
|
t.Fatalf("scheduled identities=%v", g.ids)
|
|
}
|
|
}
|