mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-23 05:22:02 +02:00
Fix failing lib_test + add test for displaying the correct cwd in the table
This commit is contained in:
parent
76f12ab64a
commit
d6a142dfe7
@ -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) {
|
func testHishtoryBackgroundSaving(t *testing.T, tester shellTester) {
|
||||||
// Setup
|
// Setup
|
||||||
defer shared.BackupAndRestore(t)()
|
defer shared.BackupAndRestore(t)()
|
||||||
|
@ -37,7 +37,7 @@ func TestBuildHistoryEntry(t *testing.T) {
|
|||||||
shared.Check(t, Setup([]string{}))
|
shared.Check(t, Setup([]string{}))
|
||||||
|
|
||||||
// Test building an actual entry for bash
|
// 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)
|
shared.Check(t, err)
|
||||||
if entry.ExitCode != 120 {
|
if entry.ExitCode != 120 {
|
||||||
t.Fatalf("history entry has unexpected exit code: %v", entry.ExitCode)
|
t.Fatalf("history entry has unexpected exit code: %v", entry.ExitCode)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user