mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-09 15:15:08 +02:00
Add HomeDirectory to HistoryEntry so we can query with or without ~/ in the cwd atom
This commit is contained in:
@ -52,6 +52,9 @@ func TestBuildHistoryEntry(t *testing.T) {
|
||||
if !strings.HasPrefix(entry.CurrentWorkingDirectory, "/") && !strings.HasPrefix(entry.CurrentWorkingDirectory, "~/") {
|
||||
t.Fatalf("history entry has unexpected cwd: %v", entry.CurrentWorkingDirectory)
|
||||
}
|
||||
if !strings.HasPrefix(entry.HomeDirectory, "/") {
|
||||
t.Fatalf("history entry has unexpected home directory: %v", entry.HomeDirectory)
|
||||
}
|
||||
if entry.Command != "ls /foo" {
|
||||
t.Fatalf("history entry has unexpected command: %v", entry.Command)
|
||||
}
|
||||
@ -74,6 +77,9 @@ func TestBuildHistoryEntry(t *testing.T) {
|
||||
if !strings.HasPrefix(entry.CurrentWorkingDirectory, "/") && !strings.HasPrefix(entry.CurrentWorkingDirectory, "~/") {
|
||||
t.Fatalf("history entry has unexpected cwd: %v", entry.CurrentWorkingDirectory)
|
||||
}
|
||||
if !strings.HasPrefix(entry.HomeDirectory, "/") {
|
||||
t.Fatalf("history entry has unexpected home directory: %v", entry.HomeDirectory)
|
||||
}
|
||||
if entry.Command != "ls /foo" {
|
||||
t.Fatalf("history entry has unexpected command: %v", entry.Command)
|
||||
}
|
||||
@ -243,7 +249,11 @@ func TestMaybeSkipBashHistTimePrefix(t *testing.T) {
|
||||
|
||||
for _, tc := range testcases {
|
||||
os.Setenv("HISTTIMEFORMAT", tc.env)
|
||||
if stripped := maybeSkipBashHistTimePrefix(tc.cmdLine); stripped != tc.expected {
|
||||
stripped, err := maybeSkipBashHistTimePrefix(tc.cmdLine)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if stripped != tc.expected {
|
||||
t.Fatalf("skipping the time prefix returned %#v (expected=%#v for %#v)", stripped, tc.expected, tc.cmdLine)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user