diff --git a/client/client_test.go b/client/client_test.go index f334d53..414c990 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -773,6 +773,37 @@ func testTimestampsAreReasonablyCorrect(t *testing.T, tester shellTester) { } } +func testTableDisplayCwd(t *testing.T, tester shellTester) { + // Setup + defer shared.BackupAndRestore(t)() + installHishtory(t, tester, "") + + // Record a command + out := tester.RunInteractiveShell(t, `cd ~/.hishtory/ +echo hello +cd /tmp/ +echo other`) + if out != "hello\nother\n" { + t.Fatalf("running echo hello had unexpected out=%#v", out) + } + + // Query for it and check that the directory gets recorded correctly + out = hishtoryQuery(t, tester, "echo hello") + if strings.Count(out, "\n") != 2 { + t.Fatalf("hishtory query has unexpected number of lines: out=%#v", out) + } + if !strings.Contains(out, "~/.hishtory/") { + t.Fatalf("hishtory query has an incorrect CWD: out=%#v", out) + } + out = hishtoryQuery(t, tester, "echo other") + if strings.Count(out, "\n") != 2 { + t.Fatalf("hishtory query has unexpected number of lines: out=%#v", out) + } + if !strings.Contains(out, "/tmp/") { + t.Fatalf("hishtory query has an incorrect CWD: out=%#v", out) + } +} + func testHishtoryBackgroundSaving(t *testing.T, tester shellTester) { // Setup defer shared.BackupAndRestore(t)() diff --git a/client/lib/lib_test.go b/client/lib/lib_test.go index fc87cb7..c1a99a6 100644 --- a/client/lib/lib_test.go +++ b/client/lib/lib_test.go @@ -37,7 +37,7 @@ func TestBuildHistoryEntry(t *testing.T) { shared.Check(t, Setup([]string{})) // Test building an actual entry for bash - entry, err := BuildHistoryEntry([]string{"unused", "saveHistoryEntry", "bash", "120", " 123 ls /foo ", "1641774958326745663"}) + entry, err := BuildHistoryEntry([]string{"unused", "saveHistoryEntry", "bash", "120", " 123 ls /foo ", "1641774958"}) shared.Check(t, err) if entry.ExitCode != 120 { t.Fatalf("history entry has unexpected exit code: %v", entry.ExitCode)