ECL, default scale, and preferred alignment entries
This commit is contained in:
@@ -162,6 +162,35 @@ topdata:
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectiveConfigIncludesTopDataValueDefaults(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
writeProjectFile(t, filepath.Join(root, ConfigFile), `
|
||||
module:
|
||||
name: Test Module
|
||||
resref: testmod
|
||||
topdata:
|
||||
source: topdata
|
||||
value_defaults:
|
||||
- dataset: racialtypes/core
|
||||
column: ECL
|
||||
value: 0
|
||||
`)
|
||||
|
||||
proj, err := Load(root)
|
||||
if err != nil {
|
||||
t.Fatalf("Load returned error: %v", err)
|
||||
}
|
||||
|
||||
defaults := proj.EffectiveConfig().TopData.ValueDefaults
|
||||
if len(defaults) != 1 {
|
||||
t.Fatalf("expected one topdata value default, got %#v", defaults)
|
||||
}
|
||||
got := defaults[0]
|
||||
if got.Dataset != "racialtypes/core" || got.Column != "ECL" || got.Value != 0 {
|
||||
t.Fatalf("unexpected topdata value default: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateLayoutRejectsInvalidTopDataValueEncodings(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mkdirAll(t, filepath.Join(root, "topdata"))
|
||||
@@ -179,6 +208,11 @@ func TestValidateLayoutRejectsInvalidTopDataValueEncodings(t *testing.T) {
|
||||
{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},
|
||||
},
|
||||
ValueDefaults: []TopDataValueDefaultConfig{
|
||||
{Dataset: "racialtypes/core", Column: "ECL", Value: 0},
|
||||
{Dataset: "racialtypes/core", Column: "ECL", Value: 1},
|
||||
{Dataset: "", Column: "", Value: 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -195,6 +229,9 @@ func TestValidateLayoutRejectsInvalidTopDataValueEncodings(t *testing.T) {
|
||||
"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",
|
||||
"topdata.value_defaults[1] duplicates an earlier dataset/column default",
|
||||
"topdata.value_defaults[2].dataset is required",
|
||||
"topdata.value_defaults[2].column is required",
|
||||
} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("expected validation error %q, got %v", want, err)
|
||||
|
||||
Reference in New Issue
Block a user