Skip to content

Commit

Permalink
Fix test harness bug by swapping to splitn
Browse files Browse the repository at this point in the history
  • Loading branch information
ddworken committed Oct 6, 2024
1 parent 49ccce7 commit 225c718
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
27 changes: 24 additions & 3 deletions client/testdata/TestTimestampFormat-tquery
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion client/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 225c718

Please sign in to comment.