From c3263c03776401ad1263a9fb8f5a44a8ed44d61b Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 17 Nov 2021 10:13:06 +0100 Subject: Refactored package structure --- config/game_test.go | 107 ---------------------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 config/game_test.go (limited to 'config/game_test.go') diff --git a/config/game_test.go b/config/game_test.go deleted file mode 100644 index b3bf107..0000000 --- a/config/game_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package config - -import "testing" - -func TestGameValidate(t *testing.T) { - // Game name - game := Game{} - if err := game.validate("invalid game name because of spaces"); err == nil { - t.Fatal("game name with spaces should not be valid") - } - // ChrootPath - game = Game{ChrootPath: "test_data/non_existant"} - if err := game.validate("test"); err == nil { - t.Fatal("non_existant ChrootPath should not be valid") - } - // FileMode - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - } - if err := game.validate("test"); err == nil { - t.Fatal("Invalid FileMode should not be valid") - } - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "abcd", - } - if err := game.validate("test"); err == nil { - t.Fatal("Invalid FileMode should not be valid") - } - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "777", - } - if err := game.validate("test"); err == nil { - t.Fatal("Invalid FileMode should not be valid") - } - // Commands are mostly tested from command_test.go - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - } - if err := game.validate("test"); err == nil { - t.Fatal("Empty Commands list should not be valid") - } - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - Commands: []string{"invalid"}, - } - if err := game.validate("test"); err == nil { - t.Fatal("Invalid command in Commands should not be valid") - } - // Env - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - Commands: []string{"wait"}, - } - if err := game.validate("test"); err != nil { - t.Fatal("Empty env list should be valid") - } - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - Commands: []string{"wait"}, - Env: map[string]string{ - "test invalid": "test", - }, - } - if err := game.validate("test"); err == nil { - t.Fatal("Spaces in environnement variable name are invalid") - } - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - Commands: []string{"wait"}, - Env: map[string]string{ - "test\000invalid": "test", - }, - } - if err := game.validate("test"); err == nil { - t.Fatal("null character in environnement variable name are invalid") - } - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - Commands: []string{"wait"}, - Env: map[string]string{ - "test=invalid": "test", - }, - } - if err := game.validate("test"); err == nil { - t.Fatal("equals symbol in environnement variable name are invalid") - } - // Valid Game entry - game = Game{ - ChrootPath: "test_data/fake_nethack_directory", - FileMode: "0777", - Commands: []string{"wait"}, - Env: map[string]string{ - "test": "test", - }, - } - if err := game.validate("test"); err != nil { - t.Fatalf("Valid game entry should pass but got error %s", err) - } -} -- cgit v1.2.3