mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-19 11:20:18 +02:00
implemented after and before atoms w/ tests for them
This commit is contained in:
@@ -271,6 +271,15 @@ func TestAdvancedQuery(t *testing.T) {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
|
||||
// Query based on cwd without the slash
|
||||
out = RunInteractiveBashCommands(t, `hishtory query cwd:tmp`)
|
||||
if !strings.Contains(out, "echo querybydir") {
|
||||
t.Fatalf("hishtory query doesn't contain result matching cwd:tmp, out=%#v", out)
|
||||
}
|
||||
if strings.Count(out, "\n") != 3 {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
|
||||
// Query based on cwd and another term
|
||||
out = RunInteractiveBashCommands(t, `hishtory query cwd:/tmp querybydir`)
|
||||
if !strings.Contains(out, "echo querybydir") {
|
||||
@@ -298,5 +307,31 @@ func TestAdvancedQuery(t *testing.T) {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
|
||||
// Query based on before: and cwd:
|
||||
out = RunInteractiveBashCommands(t, `hishtory query before:2025-07-02 cwd:/tmp`)
|
||||
if strings.Count(out, "\n") != 3 {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
out = RunInteractiveBashCommands(t, `hishtory query before:2025-07-02 cwd:tmp`)
|
||||
if strings.Count(out, "\n") != 3 {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
out = RunInteractiveBashCommands(t, `hishtory query before:2025-07-02 cwd:mp`)
|
||||
if strings.Count(out, "\n") != 3 {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
|
||||
// Query based on after: and cwd:
|
||||
out = RunInteractiveBashCommands(t, `hishtory query after:2020-07-02 cwd:/tmp`)
|
||||
if strings.Count(out, "\n") != 3 {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
|
||||
// Query based on after: that returns no results
|
||||
out = RunInteractiveBashCommands(t, `hishtory query after:2120-07-02 cwd:/tmp`)
|
||||
if strings.Count(out, "\n") != 1 {
|
||||
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
|
||||
}
|
||||
|
||||
// TODO: test the username,hostname atoms
|
||||
}
|
||||
|
Reference in New Issue
Block a user