List/range support
This commit is contained in:
@@ -125,6 +125,83 @@ validation:
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectiveConfigIncludesTopDataValueEncodings(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
writeProjectFile(t, filepath.Join(root, ConfigFile), `
|
||||
module:
|
||||
name: Test Module
|
||||
resref: testmod
|
||||
topdata:
|
||||
source: topdata
|
||||
value_encodings:
|
||||
- dataset: racialtypes/core
|
||||
column: AvailableSkinColors
|
||||
mode: packed_hex_list
|
||||
min: 0
|
||||
max: 175
|
||||
hex_width: 2
|
||||
`)
|
||||
|
||||
proj, err := Load(root)
|
||||
if err != nil {
|
||||
t.Fatalf("Load returned error: %v", err)
|
||||
}
|
||||
|
||||
encodings := proj.EffectiveConfig().TopData.ValueEncodings
|
||||
if len(encodings) != 1 {
|
||||
t.Fatalf("expected one topdata value encoding, got %#v", encodings)
|
||||
}
|
||||
got := encodings[0]
|
||||
if got.Dataset != "racialtypes/core" ||
|
||||
got.Column != "AvailableSkinColors" ||
|
||||
got.Mode != "packed_hex_list" ||
|
||||
got.Min != 0 ||
|
||||
got.Max != 175 ||
|
||||
got.HexWidth != 2 {
|
||||
t.Fatalf("unexpected topdata value encoding: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateLayoutRejectsInvalidTopDataValueEncodings(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mkdirAll(t, filepath.Join(root, "topdata"))
|
||||
mkdirAll(t, filepath.Join(root, "build"))
|
||||
|
||||
proj := &Project{
|
||||
Root: root,
|
||||
Config: Config{
|
||||
Module: ModuleConfig{Name: "Test", ResRef: "test"},
|
||||
Paths: PathConfig{Build: "build"},
|
||||
TopData: TopDataConfig{
|
||||
Source: "topdata",
|
||||
ValueEncodings: []TopDataValueEncodingConfig{
|
||||
{Dataset: "racialtypes/core", Column: "AvailableSkinColors", Mode: "packed_hex_list", Min: 0, Max: 256, HexWidth: 2},
|
||||
{Dataset: "racialtypes/core", Column: "AvailableSkinColors", Mode: "packed_hex_list", Min: 0, Max: 175, HexWidth: 2},
|
||||
{Dataset: "", Column: "AvailableHeadsMale", Mode: "unknown", Min: -1, Max: 999, HexWidth: 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := proj.ValidateLayout()
|
||||
if err == nil {
|
||||
t.Fatal("expected invalid topdata value encoding validation error")
|
||||
}
|
||||
text := err.Error()
|
||||
for _, want := range []string{
|
||||
"topdata.value_encodings[0].max does not fit in hex_width 2",
|
||||
"topdata.value_encodings[1] duplicates an earlier dataset/column encoding",
|
||||
"topdata.value_encodings[2].dataset is required",
|
||||
"topdata.value_encodings[2].mode \"unknown\" is not supported",
|
||||
"topdata.value_encodings[2].min must be zero or greater",
|
||||
"topdata.value_encodings[2].hex_width must be greater than zero",
|
||||
} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("expected validation error %q, got %v", want, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanUsesYAMLMusicConvertExtensionsWithinConfiguredDatasetRoots(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(root, "assets", "audio", "westgate"), 0o755); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user