feat: 建立统一检测任务、样本链与发病事件

This commit is contained in:
weijuesen
2026-08-14 03:31:02 +08:00
parent a25bc7abc6
commit cc93c9a053
26 changed files with 1716 additions and 32 deletions
@@ -0,0 +1,35 @@
package model
import (
"encoding/json"
"testing"
)
func TestDiseaseEventRequiresEvidenceToConfirm(t *testing.T) {
event := DiseaseEvent{Status: "confirmed"}
if err := ValidateDiseaseEventEvidence(event); err == nil {
t.Fatal("confirmed 无证据应返回错误")
}
event.Evidence = json.RawMessage(`{"result":"positive"}`)
if err := ValidateDiseaseEventEvidence(event); err != nil {
t.Fatalf("confirmed 有证据应通过: %v", err)
}
}
func TestDiseaseEventTransition(t *testing.T) {
transitions := [][2]string{
{"suspected", "confirmed"},
{"confirmed", "controlled"},
{"controlled", "closed"},
{"closed", "reopened"},
{"reopened", "confirmed"},
}
for _, tr := range transitions {
if !ValidDiseaseEventTransition(tr[0], tr[1]) {
t.Errorf("expected %s -> %s", tr[0], tr[1])
}
}
if ValidDiseaseEventTransition("suspected", "controlled") {
t.Error("suspected 不能直接 controlled")
}
}