44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"droboticflow/internal/domain"
|
|
)
|
|
|
|
func TestValidateAnnotationSegmentsRejectsOverlapAndOutOfRange(t *testing.T) {
|
|
task := domain.AnnotationTaskRecord{ClipStart: 10, ClipEnd: 20}
|
|
issues := validateAnnotationSegments([]domain.AnnotationSegment{
|
|
{ID: "one", LabelID: "a", Label: "A", Start: 9, End: 12, Confidence: 1},
|
|
{ID: "two", LabelID: "b", Label: "B", Start: 11, End: 15, Confidence: 1},
|
|
}, task)
|
|
if len(issues) < 2 {
|
|
t.Fatalf("expected range and overlap issues, got %#v", issues)
|
|
}
|
|
}
|
|
|
|
func TestValidateAnnotationSegmentsAcceptsOrderedTimeline(t *testing.T) {
|
|
task := domain.AnnotationTaskRecord{ClipStart: 0, ClipEnd: 30}
|
|
issues := validateAnnotationSegments([]domain.AnnotationSegment{
|
|
{ID: "one", LabelID: "static", Label: "静止观察", Start: 0, End: 10, Confidence: 0.9},
|
|
{ID: "two", LabelID: "steady", Label: "平稳活动", Start: 10, End: 30, Confidence: 0.8},
|
|
}, task)
|
|
if len(issues) != 0 {
|
|
t.Fatalf("unexpected issues: %#v", issues)
|
|
}
|
|
}
|
|
|
|
func TestMembershipRequiresMatchingProjectWorkgroupAndVendor(t *testing.T) {
|
|
task := domain.AnnotationTaskRecord{ProjectID: "project-a", WorkgroupID: "group-a", VendorID: "vendor-a"}
|
|
memberships := []domain.ProjectAnnotationMembershipRecord{
|
|
{ProjectID: "project-a", WorkgroupID: "group-a", VendorID: "vendor-a", AssignmentRole: domain.AnnotationRoleAnnotator},
|
|
}
|
|
if !membershipAllowsTask(memberships, task) {
|
|
t.Fatal("expected matching membership to allow task")
|
|
}
|
|
task.VendorID = "vendor-b"
|
|
if membershipAllowsTask(memberships, task) {
|
|
t.Fatal("vendor mismatch must not allow task")
|
|
}
|
|
}
|