feat: 建立统一检测任务、样本链与发病事件
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package model
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDetectionTaskRejectsInvalidTransition(t *testing.T) {
|
||||
if ValidDetectionTaskTransition("pending", "testing") {
|
||||
t.Error("pending 不能直接跳 testing")
|
||||
}
|
||||
if ValidDetectionTaskTransition("draft", "completed") {
|
||||
t.Error("draft 不能直接 completed")
|
||||
}
|
||||
if ValidDetectionTaskTransition("completed", "review") {
|
||||
t.Error("completed 不能回退")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectionTaskAllowsRequiredTransitions(t *testing.T) {
|
||||
transitions := [][2]string{
|
||||
{"draft", "pending"},
|
||||
{"pending", "assigned"},
|
||||
{"assigned", "sampling"},
|
||||
{"sampling", "testing"},
|
||||
{"testing", "review"},
|
||||
{"review", "completed"},
|
||||
{"pending", "cancelled"},
|
||||
}
|
||||
for _, tr := range transitions {
|
||||
if !ValidDetectionTaskTransition(tr[0], tr[1]) {
|
||||
t.Errorf("expected %s -> %s", tr[0], tr[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSampleTransition(t *testing.T) {
|
||||
transitions := [][2]string{
|
||||
{"created", "collected"},
|
||||
{"collected", "handed_over"},
|
||||
{"handed_over", "received"},
|
||||
{"received", "testing"},
|
||||
{"testing", "consumed"},
|
||||
{"consumed", "disposed"},
|
||||
}
|
||||
for _, tr := range transitions {
|
||||
if !ValidSampleTransition(tr[0], tr[1]) {
|
||||
t.Errorf("expected %s -> %s", tr[0], tr[1])
|
||||
}
|
||||
}
|
||||
if ValidSampleTransition("created", "testing") {
|
||||
t.Error("created 不能直接 testing")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user