From 807933b548d48bd1379742c4210754a20247ba44 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Mon, 11 Apr 2022 23:48:51 -0700 Subject: [PATCH] Updated tests, and maybe they'll pass on actions --- client/client_test.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index c53d363..be3c3c9 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -257,8 +257,17 @@ func TestAdvancedQuery(t *testing.T) { // Install hishtory 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 - _, _ = RunInteractiveBashCommandsWithoutStrictMode(t, ` + _, err := RunInteractiveBashCommandsWithoutStrictMode(t, ` set -m echo nevershouldappear notacommand @@ -266,9 +275,12 @@ func TestAdvancedQuery(t *testing.T) { echo querybydir hishtory disable `) + if err != nil { + t.Fatal(err) + } // Query based on cwd - out := RunInteractiveBashCommands(t, `hishtory query cwd:/tmp`) + 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) } @@ -384,7 +396,7 @@ func TestAdvancedQuery(t *testing.T) { if strings.Contains(out, "echo") { 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) } @@ -409,7 +421,7 @@ func TestAdvancedQuery(t *testing.T) { if strings.Contains(out, "echo") { 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) } }