24 lines
534 B
Go
24 lines
534 B
Go
package model
|
|
|
|
import "testing"
|
|
|
|
func TestValidKnowledgeTransition(t *testing.T) {
|
|
ok := [][2]string{
|
|
{"draft", "review"},
|
|
{"review", "published"},
|
|
{"published", "withdrawn"},
|
|
{"withdrawn", "review"},
|
|
}
|
|
for _, tr := range ok {
|
|
if !ValidKnowledgeTransition(tr[0], tr[1]) {
|
|
t.Errorf("expected %s -> %s", tr[0], tr[1])
|
|
}
|
|
}
|
|
if ValidKnowledgeTransition("draft", "published") {
|
|
t.Error("draft 不能直接 published")
|
|
}
|
|
if ValidKnowledgeTransition("published", "draft") {
|
|
t.Error("published 不能回草稿")
|
|
}
|
|
}
|