diff options
author | Julien Dessaux | 2021-01-12 16:33:12 +0100 |
---|---|---|
committer | Julien Dessaux | 2021-01-12 16:33:12 +0100 |
commit | 33823966901d925b34451b96bb685ab1c75cc935 (patch) | |
tree | ad9aa7d1fe3cd8c0f72f3bce2fe5c616577206a4 /config | |
parent | Improved config App tests (diff) | |
download | shell-game-launcher-33823966901d925b34451b96bb685ab1c75cc935.tar.gz shell-game-launcher-33823966901d925b34451b96bb685ab1c75cc935.tar.bz2 shell-game-launcher-33823966901d925b34451b96bb685ab1c75cc935.zip |
Properly test the minimal config contents
Diffstat (limited to 'config')
-rw-r--r-- | config/config_test.go | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/config/config_test.go b/config/config_test.go index be24a21..44df5ed 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -21,8 +21,37 @@ func TestLoadFile(t *testing.T) { // Minimal yaml file _, err = LoadFile("test_data/minimal.yaml") - if err != nil { - t.Fatal("minimal config file should load without errors") + want := Config{ + App: App{ + WorkingDirectory: "var/", + MaxUsers: 1, + AllowRegistration: true, + MaxNickLen: 15, + MenuMaxIdleTime: 600, + }, + Menus: map[string]Menu{ + "anonymous": Menu{ + MenuEntries: []MenuEntry{ + MenuEntry{ + Key: "q", + Label: "quit", + Action: "quit", + }, + }, + }, + "logged_in": Menu{ + MenuEntries: []MenuEntry{ + MenuEntry{ + Key: "q", + Label: "quit", + Action: "quit", + }, + }, + }, + }, + } + if config, err := LoadFile("test_data/minimal.yaml"); err != nil || !reflect.DeepEqual(want, config) { + t.Fatalf("minimal example failed:\nerror %v\nwant:%+v\ngot: %+v", err, want, config) } // TODO test non existant game in play actions, and duplicate @@ -78,8 +107,7 @@ func TestLoadFile(t *testing.T) { } // Complexe example - config, err := LoadFile("../example/complete.yaml") - want := Config{ + want = Config{ App: App{ WorkingDirectory: "var/", MaxUsers: 512, @@ -193,7 +221,7 @@ func TestLoadFile(t *testing.T) { }, }, } - if err != nil || !reflect.DeepEqual(want, config) { + if config, err := LoadFile("../example/complete.yaml"); err != nil || !reflect.DeepEqual(want, config) { t.Fatalf("complete example failed:\nerror %v\nwant:%+v\ngot: %+v", err, want, config) } } |