From 3448c3fdf6b24f1e65096af417abca4a1329dd83 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Thu, 7 Sep 2023 22:18:16 -0700 Subject: [PATCH] Add hishtory export test as a pre-req for testTui/search to ensure that entries are getting properly stored --- client/client_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index 4c83451..7a7341a 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -1905,10 +1905,15 @@ func testTui_search(t testing.TB) { defer testutils.BackupAndRestore(t)() tester, _, _ := setupTestTui(t) - // TODO: Consider adding a hishtory export test here to confirm that the relevant entries truly are getting stored properly, since this flakes even with 7 retries + // Check hishtory export to confirm the right commands are in the initial set of history entries + out := tester.RunInteractiveShell(t, `hishtory export`) + expected := "ls ~/\necho 'aaaaaa bbbb'\n" + if diff := cmp.Diff(expected, out); diff != "" { + t.Fatalf("hishtory export mismatch (-expected +got):\n%s", diff) + } // Check the output when there is a search - out := captureTerminalOutput(t, tester, []string{ + out = captureTerminalOutput(t, tester, []string{ "hishtory SPACE tquery ENTER", "ls", }) @@ -1921,9 +1926,9 @@ func testTui_search(t testing.TB) { "ls", "", "ENTER", }) out = strings.Split(strings.TrimSpace(strings.Split(out, "hishtory tquery")[1]), "\n")[0] - expected := `ls ~/` + expected = `ls ~/` if diff := cmp.Diff(expected, out); diff != "" { - t.Fatalf("hishtory export mismatch (-expected +got):\n%s", diff) + t.Fatalf("hishtory tquery selection mismatch (-expected +got):\n%s", diff) } // Check the output when the initial search is invalid