From b9204bf6491f58576731765dbf95d51a3da670d5 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Fri, 15 Apr 2022 18:24:58 -0700 Subject: [PATCH] add a test for a complex command getting recorded --- client/client_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index e694bae..c026e5c 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -19,8 +19,6 @@ import ( "github.com/ddworken/hishtory/shared" ) -// TODO: Change this to only start the server once for this entire file - func TestMain(m *testing.M) { defer shared.RunTestServer()() cmd := exec.Command("go", "build", "-o", "/tmp/client") @@ -246,6 +244,19 @@ echo thisisrecorded`) } } + // Add a complex command + complexCommand := "echo hello | grep complex | sed s/h/i/g; echo bar && echo \"fo 'o\"" + _, _ = RunInteractiveBashCommandsWithoutStrictMode(t, complexCommand) + + // Query for it + out = hishtoryQuery(t, "complex") + if strings.Count(out, "\n") != 2 { + t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out) + } + if !strings.Contains(out, complexCommand) { + t.Fatalf("hishtory query doesn't contain the expected complex command, out=%#v", out) + } + return userSecret } @@ -574,8 +585,6 @@ echo hello2 } } -// TODO: A test that has a complex bash pipeline - func waitForBackgroundSavesToComplete(t *testing.T) { for i := 0; i < 20; i++ { cmd := exec.Command("pidof", "hishtory")