Add HomeDirectory to HistoryEntry so we can query with or without ~/ in the cwd atom

This commit is contained in:
David Dworken
2022-09-07 23:20:31 -07:00
parent e063f34997
commit d54bece705
4 changed files with 65 additions and 29 deletions

View File

@ -529,6 +529,24 @@ hishtory disable`)
if strings.Count(out, "\n") != 4 {
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
}
// Search for a cwd based on the home directory
entry = data.MakeFakeHistoryEntry("foobar")
entry.HomeDirectory = "/home/david/"
entry.CurrentWorkingDirectory = "~/dir/"
manuallySubmitHistoryEntry(t, userSecret, entry)
out = tester.RunInteractiveShell(t, `hishtory export cwd:~/dir`)
expectedOutput := "foobar\n"
if diff := cmp.Diff(expectedOutput, out); diff != "" {
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
}
// And search with the fully expanded path
out = tester.RunInteractiveShell(t, `hishtory export cwd:/home/david/dir`)
expectedOutput = "foobar\n"
if diff := cmp.Diff(expectedOutput, out); diff != "" {
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
}
}
func testUpdate(t *testing.T, tester shellTester) {