aboutsummaryrefslogtreecommitdiff
path: root/config/config_test.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-12-26 12:54:42 +0100
committerJulien Dessaux2020-12-26 12:54:42 +0100
commitbbea9342330ff020b8e3094c849db88719915132 (patch)
treebee0f9b036947e2b03a10192d0927dfe5e0f6711 /config/config_test.go
parentBegan implementing config validation (diff)
downloadshell-game-launcher-bbea9342330ff020b8e3094c849db88719915132.tar.gz
shell-game-launcher-bbea9342330ff020b8e3094c849db88719915132.tar.bz2
shell-game-launcher-bbea9342330ff020b8e3094c849db88719915132.zip
Continued implementing config validation
Diffstat (limited to 'config/config_test.go')
-rw-r--r--config/config_test.go43
1 files changed, 37 insertions, 6 deletions
diff --git a/config/config_test.go b/config/config_test.go
index 1fcc57c..5679d06 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -19,7 +19,6 @@ func TestLoadFile(t *testing.T) {
t.Fatal("invalid_yaml config file failed without error")
}
- // TODO test non existant menu in action menu entries, and duplicate, and that anonymous and logged_in exist
// TODO test non existant game in play actions, and duplicate
//menuEntry = MenuEntry{
//Key: "p",
@@ -31,26 +30,46 @@ func TestLoadFile(t *testing.T) {
//}
t.Cleanup(func() { os.RemoveAll("var/") })
- // Invalid App example
+ // Invalid App
if _, err := LoadFile("test_data/invalid_app.yaml"); err == nil {
t.Fatal("Invalid App entry should fail to load")
}
- // Not enough menus example
+ // Not enough menus
if _, err := LoadFile("test_data/not_enough_menus.yaml"); err == nil {
t.Fatal("not enough menu entries should fail to load")
}
- // Invalid Menus example
+ // Invalid Menus
if _, err := LoadFile("test_data/invalid_menus.yaml"); err == nil {
t.Fatal("Invalid menu entry should fail to load")
}
- // no anonymous Menu example
+ // no anonymous Menu
if _, err := LoadFile("test_data/no_anonymous_menu.yaml"); err == nil {
t.Fatal("Invalid menu entry should fail to load")
}
- // no logged_in Menu example
+ // no logged_in Menu
if _, err := LoadFile("test_data/no_logged_in_menu.yaml"); err == nil {
t.Fatal("Invalid menu entry should fail to load")
}
+ // duplicate menu
+ if _, err := LoadFile("test_data/duplicate_menu.yaml"); err == nil {
+ t.Fatal("duplicate menu should fail to load")
+ }
+ // non existant menu action referenced
+ if _, err := LoadFile("test_data/non_existant_menu.yaml"); err == nil {
+ t.Fatal("menu entry referencing a non existant menu should fail to load")
+ }
+ // non existant game referenced in play action
+ if _, err := LoadFile("test_data/non_existant_game.yaml"); err == nil {
+ t.Fatal("menu entry referencing a non existant play action should fail to load")
+ }
+ // unreachable menu
+ if _, err := LoadFile("test_data/unreachable_menu.yaml"); err == nil {
+ t.Fatal("unreachable menu should fail to load")
+ }
+ // unreachable game
+ if _, err := LoadFile("test_data/unreachable_game.yaml"); err == nil {
+ t.Fatal("unreachable game should fail to load")
+ }
// Complexe example
config, err := LoadFile("../example/complete.yaml")
@@ -137,6 +156,18 @@ func TestLoadFile(t *testing.T) {
},
},
},
+ "options": Menu{
+ Banner: "Options%n=======",
+ XOffset: 5,
+ YOffset: 2,
+ MenuEntries: []MenuEntry{
+ MenuEntry{
+ Key: "z",
+ Label: "back",
+ Action: "menu logged_in",
+ },
+ },
+ },
},
Games: map[string]Game{
"nethack3.7": Game{