diff options
-rw-r--r-- | config/config_test.go | 6 | ||||
-rw-r--r-- | config/test_data/duplicate_menu.yaml | 75 | ||||
-rw-r--r-- | config/test_data/invalid_app.yaml | 14 | ||||
-rw-r--r-- | config/test_data/invalid_menus.yaml | 41 | ||||
-rw-r--r-- | config/test_data/minimal.yaml | 18 | ||||
-rw-r--r-- | config/test_data/no_anonymous_menu.yaml | 35 | ||||
-rw-r--r-- | config/test_data/no_logged_in_menu.yaml | 30 | ||||
-rw-r--r-- | config/test_data/non_existant_chopts.yaml | 68 | ||||
-rw-r--r-- | config/test_data/non_existant_game.yaml | 69 | ||||
-rw-r--r-- | config/test_data/non_existant_menu.yaml | 58 | ||||
-rw-r--r-- | config/test_data/not_enough_menus.yaml | 20 | ||||
-rw-r--r-- | config/test_data/unreachable_game.yaml | 71 | ||||
-rw-r--r-- | config/test_data/unreachable_menu.yaml | 74 |
13 files changed, 63 insertions, 516 deletions
diff --git a/config/config_test.go b/config/config_test.go index 5679d06..be24a21 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -19,6 +19,12 @@ func TestLoadFile(t *testing.T) { t.Fatal("invalid_yaml config file failed without error") } + // Minimal yaml file + _, err = LoadFile("test_data/minimal.yaml") + if err != nil { + t.Fatal("minimal config file should load without errors") + } + // TODO test non existant game in play actions, and duplicate //menuEntry = MenuEntry{ //Key: "p", diff --git a/config/test_data/duplicate_menu.yaml b/config/test_data/duplicate_menu.yaml index d2a00e2..3dbefb7 100644 --- a/config/test_data/duplicate_menu.yaml +++ b/config/test_data/duplicate_menu.yaml @@ -1,89 +1,28 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - Key: t Label: test Action: menu test - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - - Key: q - Label: quit - Action: quit logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - - Key: o - Label: edit game options - Action: menu options - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - Key: q Label: quit Action: quit test: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 + - Key: q + Label: quit + Action: quit test: - Banner: 'Duplicate Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - -Games: - nethack3.7: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" - - + - Key: a + Label: login + Action: login diff --git a/config/test_data/invalid_app.yaml b/config/test_data/invalid_app.yaml index 1986c63..ed236ea 100644 --- a/config/test_data/invalid_app.yaml +++ b/config/test_data/invalid_app.yaml @@ -1,3 +1,11 @@ -App: - WorkingDirectory: var/ - MaxUsers: -1 +Menus: + anonymous: + MenuEntries: + - Key: q + Label: quit + Action: quit + logged_in: + MenuEntries: + - Key: q + Label: quit + Action: quit diff --git a/config/test_data/invalid_menus.yaml b/config/test_data/invalid_menus.yaml index 49a321e..1df5fbf 100644 --- a/config/test_data/invalid_menus.yaml +++ b/config/test_data/invalid_menus.yaml @@ -1,58 +1,19 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - - Key: o - Label: edit game options - Action: menu options - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - Key: q Label: quit Action: quit test: - Banner: 'Shell Game Launcher%n===================' - XOffset: -1 diff --git a/config/test_data/minimal.yaml b/config/test_data/minimal.yaml new file mode 100644 index 0000000..22a0a6c --- /dev/null +++ b/config/test_data/minimal.yaml @@ -0,0 +1,18 @@ +App: + WorkingDirectory: var/ + MaxUsers: 1 + AllowRegistration: true + MaxNickLen: 15 + MenuMaxIdleTime: 600 + +Menus: + anonymous: + MenuEntries: + - Key: q + Label: quit + Action: quit + logged_in: + MenuEntries: + - Key: q + Label: quit + Action: quit diff --git a/config/test_data/no_anonymous_menu.yaml b/config/test_data/no_anonymous_menu.yaml index 2afc4ad..a015160 100644 --- a/config/test_data/no_anonymous_menu.yaml +++ b/config/test_data/no_anonymous_menu.yaml @@ -1,47 +1,18 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: - logged_in: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 + test: MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit - test: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 + logged_in: MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit - diff --git a/config/test_data/no_logged_in_menu.yaml b/config/test_data/no_logged_in_menu.yaml index f6e39fa..43d0054 100644 --- a/config/test_data/no_logged_in_menu.yaml +++ b/config/test_data/no_logged_in_menu.yaml @@ -1,46 +1,18 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit test: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit diff --git a/config/test_data/non_existant_chopts.yaml b/config/test_data/non_existant_chopts.yaml index d3ec2a5..d3f796d 100644 --- a/config/test_data/non_existant_chopts.yaml +++ b/config/test_data/non_existant_chopts.yaml @@ -1,80 +1,18 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - - Key: o - Label: edit game options - Action: menu options - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - - Key: q - Label: quit - Action: quit - options: - Banner: 'Options%n=======' - XOffset: 5 - YOffset: 2 - MenuEntries: - - Key: a - Label: edit options for Nethack 3.7 + - Key: t + Label: test Action: chopts invalid - - Key: z - Label: back - Action: menu logged_in - -Games: - nethack3.7: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" - diff --git a/config/test_data/non_existant_game.yaml b/config/test_data/non_existant_game.yaml index c386e1a..9bf6a38 100644 --- a/config/test_data/non_existant_game.yaml +++ b/config/test_data/non_existant_game.yaml @@ -1,81 +1,18 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 + - Key: t + Label: test Action: play invalid - - Key: o - Label: edit game options - Action: menu options - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - - Key: q - Label: quit - Action: quit - options: - Banner: 'Options%n=======' - XOffset: 5 - YOffset: 2 - MenuEntries: - - Key: a - Label: edit options for Nethack 3.7 - Action: chopts nethack3.7 - - Key: z - Label: back - Action: menu logged_in - -Games: - nethack3.7: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" - - diff --git a/config/test_data/non_existant_menu.yaml b/config/test_data/non_existant_menu.yaml index 2890ee8..f0f30a3 100644 --- a/config/test_data/non_existant_menu.yaml +++ b/config/test_data/non_existant_menu.yaml @@ -1,72 +1,18 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - Key: t Label: test - Action: menu test - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - - Key: q - Label: quit - Action: quit + Action: menu invalid logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - - Key: o - Label: edit game options - Action: menu invalid - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - Key: q Label: quit Action: quit - -Games: - nethack3.7: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" - diff --git a/config/test_data/not_enough_menus.yaml b/config/test_data/not_enough_menus.yaml index db3b72c..f585f44 100644 --- a/config/test_data/not_enough_menus.yaml +++ b/config/test_data/not_enough_menus.yaml @@ -1,29 +1,13 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: - anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 + test: MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit diff --git a/config/test_data/unreachable_game.yaml b/config/test_data/unreachable_game.yaml index a6a8977..5af610b 100644 --- a/config/test_data/unreachable_game.yaml +++ b/config/test_data/unreachable_game.yaml @@ -1,90 +1,21 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - - Key: o - Label: edit game options - Action: menu options - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - Key: q Label: quit Action: quit - options: - Banner: 'Options%n=======' - XOffset: 5 - YOffset: 2 - MenuEntries: - - Key: a - Label: edit options for Nethack 3.7 - Action: chopts nethack3.7 - - Key: z - Label: back - Action: menu logged_in Games: - nethack3.7: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" unreachable: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" diff --git a/config/test_data/unreachable_menu.yaml b/config/test_data/unreachable_menu.yaml index 27da191..f947cf7 100644 --- a/config/test_data/unreachable_menu.yaml +++ b/config/test_data/unreachable_menu.yaml @@ -1,87 +1,23 @@ App: WorkingDirectory: var/ - MaxUsers: 512 + MaxUsers: 1 AllowRegistration: true MaxNickLen: 15 MenuMaxIdleTime: 600 - PostLoginCommands: - - mkdir %w/userdata/%u - - mkdir %w/userdata/%u/dumplog - - mkdir %w/userdata/%u/ttyrec Menus: anonymous: - Banner: 'Shell Game Launcher - Anonymous access%n======================================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: l - Label: login - Action: login - - Key: r - Label: register - Action: register - - Key: w - Label: watch - Action: watch_menu - Key: q Label: quit Action: quit logged_in: - Banner: 'Shell Game Launcher%n===================' - XOffset: 5 - YOffset: 2 MenuEntries: - - Key: p - Label: play Nethack 3.7 - Action: play nethack3.7 - - Key: o - Label: edit game options - Action: menu options - - Key: w - Label: watch - Action: watch - - Key: r - Label: replay - Action: replay - - Key: c - Label: change password - Action: passwd - - Key: m - Label: change email - Action: chmail - Key: q Label: quit Action: quit - options: - Banner: 'Options%n=======' - XOffset: 5 - YOffset: 2 + test: MenuEntries: - - Key: a - Label: edit options for Nethack 3.7 - Action: chopts nethack3.7 - - Key: z - Label: back - Action: menu logged_in - unreachable: - Banner: 'Options%n=======' - XOffset: 5 - YOffset: 2 - MenuEntries: - - Key: a - Label: edit options for Nethack 3.7 - Action: chopts nethack3.7 - -Games: - nethack3.7: - ChrootPath: /opt/nethack - FileMode: "0666" - ScoreCommands: - - exec /games/nethack -s all - - wait - Commands: - - cp /games/var/save/%u%n.gz /games/var/save/%u%n.gz.bak - - exec /games/nethack -u %n - Env: - NETHACKOPTIONS: "@%ruserdata/%n/%n.nhrc" + - Key: q + Label: quit + Action: quit |