From a76be1337502c618bc62f760f4f9379fbf09999d Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 19 Nov 2023 01:13:20 -0800 Subject: [PATCH] More test fixes --- client/client_test.go | 15 +++++++++------ client/lib/goldens/TestTui-InitialInvalidSearch | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index a70356c..69b0d1c 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -291,7 +291,7 @@ echo thisisrecorded`) exitCodeMatcher := `0` pipefailMatcher := `set -em?o pipefail` line1Matcher := `Hostname` + tableDividerMatcher + `CWD` + tableDividerMatcher + `Timestamp` + tableDividerMatcher + `Runtime` + tableDividerMatcher + `Exit Code` + tableDividerMatcher + `Command\s*\n` - line2Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + `N/A` + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + `hishtory query` + tableDividerMatcher + `\n` + line2Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + time.DateTime + tableDividerMatcher + `N/A` + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + `hishtory query` + tableDividerMatcher + `\n` line3Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + pipefailMatcher + tableDividerMatcher + `\n` line4Matcher := hostnameMatcher + tableDividerMatcher + pathMatcher + tableDividerMatcher + datetimeMatcher + tableDividerMatcher + runtimeMatcher + tableDividerMatcher + exitCodeMatcher + tableDividerMatcher + `echo thisisrecorded` + tableDividerMatcher + `\n` require.Regexp(t, regexp.MustCompile(line1Matcher), out) @@ -348,8 +348,9 @@ hishtory disable`) // A super basic query just to ensure the basics are working out := hishtoryQuery(t, tester, `echo`) - require.Contains(t, out, "echo querybydir", "hishtory query doesn't contain result matching echo querybydir") - if strings.Count(out, "\n") != 4 { + require.Contains(t, out, "echo querybydir") + require.Contains(t, out, "echo nevershouldappear") + if strings.Count(out, "\n") != 3 { t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out) } @@ -1012,7 +1013,8 @@ echo other`) if strings.Count(out, "\n") != 6 { t.Fatalf("hishtory query has unexpected number of lines=%d: out=%#v", strings.Count(out, "\n"), out) } - expected := []string{"echo hello", "echo other", "hishtory query ech"} + require.Contains(t, out, "hishtory query ech") + expected := []string{"echo hello", "echo other"} for _, item := range expected { require.Contains(t, out, item) if strings.Count(out, item) != 1 { @@ -1392,7 +1394,7 @@ ls /tmp`, randomCmdUuid, randomCmdUuid) // Redact it without HISHTORY_REDACT_FORCE out, err := tester.RunInteractiveShellRelaxed(t, `yes | hishtory redact hello`) require.NoError(t, err) - if out != "This will permanently delete 1 entries, are you sure? [y/N] " { + if out != "This will permanently delete 2 entries, are you sure? [y/N] " { t.Fatalf("hishtory redact gave unexpected output=%#v", out) } @@ -1955,8 +1957,9 @@ func testControlR(t *testing.T, tester shellTester, shellName string, onlineStat _, _ = tester.RunInteractiveShellRelaxed(t, ` hishtory disable`) _, _ = tester.RunInteractiveShellRelaxed(t, `hishtory config-set enable-control-r true`) - // Insert a few hishtory entries + // Insert a few hishtory entries that we'll use for testing into an empty DB db := hctx.GetDb(hctx.MakeContext()) + require.NoError(t, db.Delete(&data.HistoryEntry{}).Commit().Error) e1 := testutils.MakeFakeHistoryEntry("ls ~/") e1.CurrentWorkingDirectory = "/etc/" e1.Hostname = "server" diff --git a/client/lib/goldens/TestTui-InitialInvalidSearch b/client/lib/goldens/TestTui-InitialInvalidSearch index 6429d61..b628fec 100644 --- a/client/lib/goldens/TestTui-InitialInvalidSearch +++ b/client/lib/goldens/TestTui-InitialInvalidSearch @@ -2,7 +2,6 @@ foo: - Search Query: > ls ┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐