From 19e747f1669d8ae64619686569929a59d5722b8c Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 13 Jan 2021 15:38:19 +0100 Subject: Finished implementing config tests --- config/config_test.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'config/config_test.go') 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", -- cgit v1.2.3