Updated tests, and maybe they'll pass on actions

This commit is contained in:
David Dworken 2022-04-11 23:48:51 -07:00
parent 9f1b258a7f
commit 807933b548

View File

@ -257,8 +257,17 @@ func TestAdvancedQuery(t *testing.T) {
// Install hishtory // Install hishtory
userSecret := installHishtory(t, "") userSecret := installHishtory(t, "")
// An empty hishtory query
out := RunInteractiveBashCommands(t, `hishtory query`)
if strings.Count(out, "\n") != 3 {
t.Fatalf("hishtory query has unexpected out %#v", out)
}
if strings.Count(out, "/tmp/client install") != 1 {
t.Fatalf("hishtory query has unexpected out %#v", out)
}
// Run some commands we can query for // Run some commands we can query for
_, _ = RunInteractiveBashCommandsWithoutStrictMode(t, ` _, err := RunInteractiveBashCommandsWithoutStrictMode(t, `
set -m set -m
echo nevershouldappear echo nevershouldappear
notacommand notacommand
@ -266,9 +275,12 @@ func TestAdvancedQuery(t *testing.T) {
echo querybydir echo querybydir
hishtory disable hishtory disable
`) `)
if err != nil {
t.Fatal(err)
}
// Query based on cwd // Query based on cwd
out := RunInteractiveBashCommands(t, `hishtory query cwd:/tmp`) out = RunInteractiveBashCommands(t, `hishtory query cwd:/tmp`)
if !strings.Contains(out, "echo querybydir") { if !strings.Contains(out, "echo querybydir") {
t.Fatalf("hishtory query doesn't contain result matching cwd:/tmp, out=%#v", out) t.Fatalf("hishtory query doesn't contain result matching cwd:/tmp, out=%#v", out)
} }
@ -384,7 +396,7 @@ func TestAdvancedQuery(t *testing.T) {
if strings.Contains(out, "echo") { if strings.Contains(out, "echo") {
t.Fatalf("hishtory query contains unexpected result, out=%#v", out) t.Fatalf("hishtory query contains unexpected result, out=%#v", out)
} }
if strings.Count(out, "\n") != 7 { if strings.Count(out, "\n") != 9 {
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out) t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
} }
@ -409,7 +421,7 @@ func TestAdvancedQuery(t *testing.T) {
if strings.Contains(out, "echo") { if strings.Contains(out, "echo") {
t.Fatalf("hishtory query contains unexpected result, out=%#v", out) t.Fatalf("hishtory query contains unexpected result, out=%#v", out)
} }
if strings.Count(out, "\n") != 7 { if strings.Count(out, "\n") != 9 {
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out) t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
} }
} }