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 --- client/input_test.go | 60 ---------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 client/input_test.go (limited to 'client/input_test.go') diff --git a/client/input_test.go b/client/input_test.go deleted file mode 100644 index fe8feeb..0000000 --- a/client/input_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package client - -import ( - "os" - "shell-game-launcher/config" - "testing" -) - -func TestGetValidInput(t *testing.T) { - realStdin := os.Stdin - t.Cleanup(func() { os.Stdin = realStdin }) - - // Complete menu, no input error - state := State{ - config: &config.Config{ - Menus: map[string]config.Menu{ - "test": config.Menu{ - Banner: "TEST TEST TEST", - MenuEntries: []config.MenuEntry{ - config.MenuEntry{ - Key: "w", - Label: "wait entry", - Action: "wait", - }, - config.MenuEntry{ - Key: "q", - Label: "quit entry", - Action: "quit", - }, - }, - }, - }, - }, - currentMenu: "test", - login: "", - } - r, w, _ := os.Pipe() - os.Stdin = r - - // Simply test quit entry - w.WriteString("q") - if cmd, err := state.getValidInput(); err != nil || cmd != "quit" { - t.Fatalf("Input handled incorrectly:\nwant: wait\ngot: %s\nerror: %s\n", cmd, err) - } - // test quit entry after wrong keys - w.WriteString("abcdq") - if cmd, err := state.getValidInput(); err != nil || cmd != "quit" { - t.Fatalf("Input handled incorrectly:\nwant: wait\ngot: %s\nerror: %s\n", cmd, err) - } - // test wait entry with valid quit after - w.WriteString("wq") - if cmd, err := state.getValidInput(); err != nil || cmd != "wait" { - t.Fatalf("Input handled incorrectly:\nwant: wait\ngot: %s\nerror: %s\n", cmd, err) - } - // test input error - w.Close() - if cmd, err := state.getValidInput(); err == nil { - t.Fatalf("Input handled incorrectly:\nwant: wait\ngot: %s\nerror: %s\n", cmd, err) - } -} -- cgit v1.2.3