More test fixes

This commit is contained in:
David Dworken 2023-11-19 01:13:20 -08:00
parent d01e2913eb
commit a76be13375
No known key found for this signature in database
2 changed files with 9 additions and 7 deletions

View File

@ -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"

View File

@ -2,7 +2,6 @@ foo:
Search Query: > ls
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐