1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package validate
import (
"strings"
"testing"
"thehouseoficarus/internal/behavior"
)
// Regression: a talk config with nodes but no "start" node is dead content at
// runtime; validation must report it.
func TestValidateTalkConfigRequiresStartNode(t *testing.T) {
cfg := &behavior.TalkConfig{Nodes: map[string]behavior.TalkNode{
"greet": {Messages: []string{"hi"}},
}}
issues := validateTalkConfig("test", cfg, nil, nil, nil, nil)
found := false
for _, iss := range issues {
if strings.Contains(iss.Message, "start") {
found = true
}
}
if !found {
t.Fatalf("missing start node not reported: %+v", issues)
}
clean := &behavior.TalkConfig{Nodes: map[string]behavior.TalkNode{"start": {}}}
for _, iss := range validateTalkConfig("test", clean, nil, nil, nil, nil) {
if strings.Contains(iss.Message, "start") {
t.Fatalf("start node wrongly reported: %+v", iss)
}
}
}
// Regression: a gather drop with weight <= 0 can never be selected (the
// weighted roll has zero total); it must be flagged.
func TestValidateGatherWarnsOnWeightlessDrop(t *testing.T) {
cfg := &behavior.GatherConfig{Drops: []behavior.DropEntry{{ItemID: "ore", Weight: 0}}}
issues := validateGather("test", cfg, map[string]bool{"ore": true}, map[string]bool{})
found := false
for _, iss := range issues {
if strings.Contains(iss.Message, "weight") {
found = true
}
}
if !found {
t.Fatalf("weightless drop not warned: %+v", issues)
}
}
|