add a test for a complex command getting recorded

This commit is contained in:
David Dworken 2022-04-15 18:24:58 -07:00
parent 5b59141c3a
commit b9204bf649

View File

@ -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")