aboutsummaryrefslogtreecommitdiff
path: root/config/menu.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-01-12 15:55:41 +0100
committerJulien Dessaux2021-01-12 15:55:41 +0100
commit8c03774e1f05a1b9a87c5231562ba39989604773 (patch)
treea40aa7a2535ac565964059f798afb65a747e6416 /config/menu.go
parentContinued implementing config validation (diff)
downloadshell-game-launcher-8c03774e1f05a1b9a87c5231562ba39989604773.tar.gz
shell-game-launcher-8c03774e1f05a1b9a87c5231562ba39989604773.tar.bz2
shell-game-launcher-8c03774e1f05a1b9a87c5231562ba39989604773.zip
Updated menu tests to account properly for duplicate keys
Diffstat (limited to 'config/menu.go')
-rw-r--r--config/menu.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/config/menu.go b/config/menu.go
index 004c7fe..a442036 100644
--- a/config/menu.go
+++ b/config/menu.go
@@ -47,13 +47,12 @@ func (m *Menu) validate(name string) error {
return errors.New("YOffset must be a positive integer")
}
// MenuEntries
- keys := make(map[string]bool)
+ if len(m.MenuEntries) == 0 {
+ return errors.New("A Menu needs MenuEntries to be valid")
+ }
+ // Duplicate detection is natively handled by the yaml parser
for i := 0; i < len(m.MenuEntries); i++ {
m.MenuEntries[i].validate()
- if _, duplicate := keys[m.MenuEntries[i].Key]; duplicate {
- return errors.New("A Menu has a duplicate key " + m.MenuEntries[i].Key)
- }
- keys[m.MenuEntries[i].Key] = true
if m.MenuEntries[i].Action == "menu "+name {
return errors.New("A menu shall not loop on itself")
}