diff options
author | Julien Dessaux | 2021-01-13 15:38:19 +0100 |
---|---|---|
committer | Julien Dessaux | 2021-01-13 15:38:19 +0100 |
commit | 19e747f1669d8ae64619686569929a59d5722b8c (patch) | |
tree | 370b8742f7563e1b750f5ad494e654a7fcc24838 /config/config_test.go | |
parent | Properly test the minimal config contents (diff) | |
download | shell-game-launcher-19e747f1669d8ae64619686569929a59d5722b8c.tar.gz shell-game-launcher-19e747f1669d8ae64619686569929a59d5722b8c.tar.bz2 shell-game-launcher-19e747f1669d8ae64619686569929a59d5722b8c.zip |
Finished implementing config tests
Diffstat (limited to 'config/config_test.go')
-rw-r--r-- | config/config_test.go | 24 |
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", |