Fix test harness bug by swapping to splitn

This commit is contained in:
David Dworken 2024-10-06 12:05:11 -07:00
parent 49ccce74e1
commit 225c718a28
No known key found for this signature in database
3 changed files with 26 additions and 5 deletions

View File

@ -2734,7 +2734,7 @@ func TestTimestampFormat(t *testing.T) {
// And check that it is displayed in both the tui and the classic view
out := hishtoryQuery(t, tester, "-pipefail -tablesizing")
testutils.CompareGoldens(t, out, "TestTimestampFormat-query")
out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery ENTER", "-pipefail SPACE -tablesizing"})
out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery ENTER", "table_cmd SPACE -tquery"})
out = stripRequiredPrefix(t, out, "hishtory tquery")
testutils.CompareGoldens(t, out, "TestTimestampFormat-tquery")
}

View File

@ -1,6 +1,27 @@
Search Query: > -pipefail -tablesizing
Search Query: > table_cmd -tquery
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Hostname CWD Timestamp Runtime Exit Code Command │
│ Hostname CWD Timestamp Runtime Exit Code Command
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ ghaction-runner-hostname ~/work/hishtory/hishtory 2024/Sep/28 12:46 N/A 0
│ localhost ~/foo/ 2022/Apr/16 01:03 24s 3 table_cmd2 │
│ localhost /tmp/ 2022/Apr/16 01:03 4s 2 table_cmd1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa… │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history • ctrl+h help

View File

@ -361,7 +361,7 @@ func stripShellPrefix(out string) string {
func stripRequiredPrefix(t *testing.T, out, prefix string) string {
require.Contains(t, out, prefix)
return strings.TrimSpace(strings.Split(out, prefix)[1])
return strings.TrimSpace(strings.SplitN(out, prefix, 2)[1])
}
func stripTuiCommandPrefix(t *testing.T, out string) string {