feat: Doing more polishing (M8b)
This commit is contained in:
+16
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var (
|
||||
docTypes = set([]string{"memo", "telegram", "petition", "report", "letter"})
|
||||
cardKeys = set([]string{"id", "category", "doc", "sender", "weight", "once", "cooldownDays", "followUpOnly", "conditions", "title", "body", "yes", "no"})
|
||||
cardKeys = set([]string{"id", "category", "doc", "sender", "weight", "once", "cooldownDays", "followUpOnly", "conditions", "scenarios", "title", "body", "yes", "no"})
|
||||
optionKeys = set([]string{"label", "effects", "setFlags", "clearFlags", "followUp"})
|
||||
condKeys = set([]string{"min", "max", "flags", "notFlags", "dayMin", "dayMax"})
|
||||
effectKeys = set([]string{"stat", "sector", "revenue", "oneOff", "extraSpending", "delta", "days", "bias"})
|
||||
@@ -201,6 +201,10 @@ func TestCards(t *testing.T) {
|
||||
t.Errorf("cards/index.json lists %s but the file does not exist", f)
|
||||
}
|
||||
|
||||
scenarioIDs := map[string]bool{}
|
||||
for _, sid := range load(t, "data/scenarios/index.json")["scenarios"].([]any) {
|
||||
scenarioIDs[sid.(string)] = true
|
||||
}
|
||||
followOnly := map[string]bool{}
|
||||
total := 0
|
||||
perCategory := map[string]int{}
|
||||
@@ -249,6 +253,17 @@ func TestCards(t *testing.T) {
|
||||
if !isLocalized(card["title"]) || !isLocalized(card["body"]) {
|
||||
t.Errorf("%s: title and body need non-empty en and fr", id)
|
||||
}
|
||||
if list, ok := card["scenarios"]; ok {
|
||||
ids, _ := list.([]any)
|
||||
if len(ids) == 0 {
|
||||
t.Errorf("%s: scenarios must be a non-empty list of scenario ids", id)
|
||||
}
|
||||
for _, raw := range ids {
|
||||
if sid, _ := raw.(string); !scenarioIDs[sid] {
|
||||
t.Errorf("%s: unknown scenario %q", id, raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
if w, ok := card["weight"]; ok {
|
||||
if f, isNum := w.(float64); !isNum || f <= 0 {
|
||||
t.Errorf("%s: weight must be positive", id)
|
||||
|
||||
Reference in New Issue
Block a user