feat: 完善环境规则、会诊治理、知识审核与效果评估
This commit is contained in:
@@ -8,9 +8,11 @@ import (
|
||||
|
||||
func TestValidConsultationTransition(t *testing.T) {
|
||||
ok := [][2]string{
|
||||
{"pending", "consulting"},
|
||||
{"pending", "resolved"},
|
||||
{"consulting", "resolved"},
|
||||
{"unassigned", "assigned"},
|
||||
{"assigned", "accepted"},
|
||||
{"assigned", "needs_info"},
|
||||
{"accepted", "resolved"},
|
||||
{"needs_info", "resolved"},
|
||||
{"resolved", "archived"},
|
||||
}
|
||||
for _, c := range ok {
|
||||
@@ -19,7 +21,8 @@ func TestValidConsultationTransition(t *testing.T) {
|
||||
}
|
||||
}
|
||||
bad := [][2]string{
|
||||
{"pending", "archived"},
|
||||
{"unassigned", "archived"},
|
||||
{"unassigned", "resolved"},
|
||||
{"resolved", "resolved"},
|
||||
{"archived", "pending"},
|
||||
{"", "resolved"},
|
||||
@@ -31,15 +34,41 @@ func TestValidConsultationTransition(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsultationRejectsArchiveBeforeResolution(t *testing.T) {
|
||||
if ValidConsultationTransition("accepted", "archived") {
|
||||
t.Fatal("accepted 不能直接归档")
|
||||
}
|
||||
if ValidConsultationTransition("unassigned", "archived") {
|
||||
t.Fatal("unassigned 不能直接归档")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsultationSLAMarksOverdue(t *testing.T) {
|
||||
now := time.Now()
|
||||
deadline := now.Add(-time.Hour)
|
||||
task := Consultation{Status: "assigned", SLADeadline: &deadline}
|
||||
if state := ConsultationSLAState(task, now); state != "overdue" {
|
||||
t.Fatalf("SLA 状态 = %s, want overdue", state)
|
||||
}
|
||||
future := now.Add(time.Hour)
|
||||
task.SLADeadline = &future
|
||||
if state := ConsultationSLAState(task, now); state != "on_time" {
|
||||
t.Fatalf("SLA 状态 = %s, want on_time", state)
|
||||
}
|
||||
if state := ConsultationSLAState(Consultation{}, now); state != "unscheduled" {
|
||||
t.Fatalf("SLA 状态 = %s, want unscheduled", state)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsultationSnapshotJSON(t *testing.T) {
|
||||
now := time.Now()
|
||||
s := ConsultationSnapshot{
|
||||
RoomName: "蚕房1#",
|
||||
LampTest: &LampTest{ID: "lamp-1", Status: "resulted"},
|
||||
Inspection: &InspectionRecord{ID: "insp-1", AIStatus: "done"},
|
||||
Batch: &Batch{ID: "batch-1", Name: "批次A"},
|
||||
RoomName: "蚕房1#",
|
||||
LampTest: &LampTest{ID: "lamp-1", Status: "resulted"},
|
||||
Inspection: &InspectionRecord{ID: "insp-1", AIStatus: "done"},
|
||||
Batch: &Batch{ID: "batch-1", Name: "批次A"},
|
||||
WeatherAlerts: []WeatherAlert{{Disease: "白僵病", Level: "orange"}},
|
||||
CreatedAt: now,
|
||||
CreatedAt: now,
|
||||
}
|
||||
raw, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user