39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package api
|
|
|
|
import (
|
|
"droboticflow/internal/domain"
|
|
"droboticflow/internal/store"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSourceValidationProgressSeparatesQueueAndWorker(t *testing.T) {
|
|
db := store.NewMemoryStore()
|
|
s := &server{store: db}
|
|
ctx := t.Context()
|
|
task := domain.AnnotationTaskRecord{ID: "task", OrganizationID: "org"}
|
|
job := &domain.AnnotationProcessingJob{Stage: "validating", Status: "queued", SourceFingerprint: "source"}
|
|
if got := s.annotationProcessingStage(ctx, "org", job); got != "waiting_source" {
|
|
t.Fatal(got)
|
|
}
|
|
if err := db.EnqueueAnnotationSourceIndex(ctx, task, "source", false); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := s.annotationProcessingStage(ctx, "org", job); got != "waiting_source" {
|
|
t.Fatal(got)
|
|
}
|
|
now := time.Now().UTC()
|
|
claimed, err := db.ClaimAnnotationIndex(ctx, "worker", now.Format(time.RFC3339Nano), now.Add(time.Minute).Format(time.RFC3339Nano))
|
|
if err != nil || claimed == nil {
|
|
t.Fatal(claimed, err)
|
|
}
|
|
if got := s.annotationProcessingStage(ctx, "org", job); got != "validating" {
|
|
t.Fatal(got)
|
|
}
|
|
job.Status = "failed"
|
|
job.Stage = "failed"
|
|
if got := s.annotationProcessingStage(ctx, "org", job); got != "failed" {
|
|
t.Fatal(got)
|
|
}
|
|
}
|