forked from longtao.wu/droboticflow
44 lines
1.9 KiB
Go
44 lines
1.9 KiB
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"droboticflow/internal/domain"
|
|
)
|
|
|
|
func TestEarliestRejectTargetSelectsEarliestConfiguredStage(t *testing.T) {
|
|
batch := &domain.HumanBatchRecord{Stages: domain.DefaultAnnotationHumanStages()}
|
|
target, ok := earliestRejectTarget(
|
|
batch,
|
|
[]string{"split_annotation", "semantic_annotation"},
|
|
[]string{"semantic_annotation", "split_annotation"},
|
|
)
|
|
if !ok || target != "split_annotation" {
|
|
t.Fatalf("target=%q ok=%v", target, ok)
|
|
}
|
|
}
|
|
|
|
func TestEarliestRejectTargetRejectsUnknownStage(t *testing.T) {
|
|
batch := &domain.HumanBatchRecord{Stages: domain.DefaultAnnotationHumanStages()}
|
|
if target, ok := earliestRejectTarget(batch, []string{"semantic_annotation"}, []string{"training"}); ok || target != "" {
|
|
t.Fatalf("unexpected target=%q ok=%v", target, ok)
|
|
}
|
|
}
|
|
|
|
func TestAllowedHumanReopenStagesKeepsRejectZoneSeparateFromRework(t *testing.T) {
|
|
batch := &domain.HumanBatchRecord{Stages: domain.DefaultAnnotationHumanStages()}
|
|
splitQuality := allowedHumanReopenStages(batch, "split_quality_review")
|
|
if len(splitQuality) != 2 || splitQuality[0] != "split_annotation" || splitQuality[1] != "split_quality_review" {
|
|
t.Fatalf("split quality reopen stages=%#v", splitQuality)
|
|
}
|
|
quality := allowedHumanReopenStages(batch, "quality_review")
|
|
if len(quality) != 4 || quality[0] != "split_annotation" || quality[3] != "quality_review" {
|
|
t.Fatalf("quality reopen stages=%#v", quality)
|
|
}
|
|
legacyAcceptanceBatch := &domain.HumanBatchRecord{Stages: append(domain.DefaultAnnotationHumanStages(), domain.HumanStageDefinition{ID: "acceptance", Label: "最终验收", Kind: domain.HumanStageAcceptance, RequiredRole: "acceptance_reviewer"})}
|
|
acceptance := allowedHumanReopenStages(legacyAcceptanceBatch, "acceptance")
|
|
if len(acceptance) != 4 || containsHumanStage(acceptance, "acceptance") {
|
|
t.Fatalf("acceptance must reopen an earlier production stage: %#v", acceptance)
|
|
}
|
|
}
|