aboutsummaryrefslogtreecommitdiff
path: root/config/config_test.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-01-13 15:38:19 +0100
committerJulien Dessaux2021-01-13 15:38:19 +0100
commit19e747f1669d8ae64619686569929a59d5722b8c (patch)
tree370b8742f7563e1b750f5ad494e654a7fcc24838 /config/config_test.go
parentProperly test the minimal config contents (diff)
downloadshell-game-launcher-19e747f1669d8ae64619686569929a59d5722b8c.tar.gz
shell-game-launcher-19e747f1669d8ae64619686569929a59d5722b8c.tar.bz2
shell-game-launcher-19e747f1669d8ae64619686569929a59d5722b8c.zip
Finished implementing config tests
Diffstat (limited to '')
-rw-r--r--config/config_test.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/config/config_test.go b/config/config_test.go
index 44df5ed..2bc5489 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -54,16 +54,6 @@ func TestLoadFile(t *testing.T) {
t.Fatalf("minimal example failed:\nerror %v\nwant:%+v\ngot: %+v", err, want, config)
}
- // TODO test non existant game in play actions, and duplicate
- //menuEntry = MenuEntry{
- //Key: "p",
- //Label: "play non existant game",
- //Action: "play nonexistant",
- //}
- //if err := menuEntry.validate(); err == nil {
- //t.Fatal("An inexistant game cannot be played")
- //}
-
t.Cleanup(func() { os.RemoveAll("var/") })
// Invalid App
if _, err := LoadFile("test_data/invalid_app.yaml"); err == nil {
@@ -101,10 +91,18 @@ func TestLoadFile(t *testing.T) {
if _, err := LoadFile("test_data/unreachable_menu.yaml"); err == nil {
t.Fatal("unreachable menu should fail to load")
}
+ // invalid game
+ if _, err := LoadFile("test_data/invalid_game.yaml"); err == nil {
+ t.Fatal("invalid game should fail to load")
+ }
// unreachable game
if _, err := LoadFile("test_data/unreachable_game.yaml"); err == nil {
t.Fatal("unreachable game should fail to load")
}
+ // duplicate game
+ if _, err := LoadFile("test_data/duplicate_game.yaml"); err == nil {
+ t.Fatal("unreachable game should fail to load")
+ }
// Complexe example
want = Config{
@@ -205,12 +203,8 @@ func TestLoadFile(t *testing.T) {
},
Games: map[string]Game{
"nethack3.7": Game{
- ChrootPath: "/opt/nethack",
+ ChrootPath: "test_data/fake_nethack_directory",
FileMode: "0666",
- ScoreCommands: []string{
- "exec /games/nethack -s all",
- "wait",
- },
Commands: []string{
"cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak",
"exec /games/nethack -u %n",