mirror of
https://github.com/ddworken/hishtory.git
synced 2024-12-24 15:58:52 +01:00
Add a basic test for defining a custom column
This commit is contained in:
parent
d3c631b191
commit
9ef3b7890c
@ -1773,7 +1773,7 @@ func captureTerminalOutputWithShellName(t *testing.T, tester shellTester, overri
|
||||
}
|
||||
fullCommand += " sleep " + sleepAmount + "\n"
|
||||
for _, cmd := range commands {
|
||||
fullCommand += " tmux send -t foo "
|
||||
fullCommand += " tmux send -t foo -- "
|
||||
fullCommand += cmd
|
||||
fullCommand += "\n"
|
||||
fullCommand += " sleep " + sleepAmount + "\n"
|
||||
@ -1879,7 +1879,25 @@ func testControlR(t *testing.T, tester shellTester, shellName string) {
|
||||
}
|
||||
out = strings.TrimSpace(strings.Split(out, "\n\n\n")[1])
|
||||
}
|
||||
compareGoldens(t, out, "testControlR-CustomColumns")
|
||||
compareGoldens(t, out, "testControlR-displayedColumns")
|
||||
|
||||
// Add a custom column
|
||||
tester.RunInteractiveShell(t, `hishtory config-add custom-columns foo "echo foo"`)
|
||||
tester.RunInteractiveShell(t, ` hishtory enable`)
|
||||
tester.RunInteractiveShell(t, `ls /`)
|
||||
tester.RunInteractiveShell(t, ` hishtory disable`)
|
||||
|
||||
// And run a query and confirm it is displayed
|
||||
tester.RunInteractiveShell(t, `hishtory config-add displayed-columns foo`)
|
||||
out = captureTerminalOutputWithShellName(t, tester, shellName, []string{"C-R", "-pipefail"})
|
||||
out = strings.TrimSpace(out)
|
||||
if tester.ShellName() == "bash" {
|
||||
if !strings.Contains(out, "\n\n\n") {
|
||||
t.Fatalf("failed to find separator in %#v", out)
|
||||
}
|
||||
out = strings.TrimSpace(strings.Split(out, "\n\n\n")[1])
|
||||
}
|
||||
compareGoldens(t, out, "testControlR-customColumn")
|
||||
|
||||
// Disable control-r
|
||||
_, _ = tester.RunInteractiveShellRelaxed(t, `hishtory config-set enable-control-r false`)
|
||||
|
26
client/lib/goldens/testControlR-customColumn
Normal file
26
client/lib/goldens/testControlR-customColumn
Normal file
@ -0,0 +1,26 @@
|
||||
Search Query: > -pipefail
|
||||
|
||||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Hostname Exit Code Command foo │
|
||||
│─────────────────────────────────────────────────────────────────────────────│
|
||||
│ Davids-MacBook-Air.local 0 ls / foo │
|
||||
│ localhost 2 echo 'bar' & │
|
||||
│ localhost 2 echo 'aaaaaa bbbb' │
|
||||
│ localhost 2 ls ~/bar/ │
|
||||
│ localhost 2 ls ~/foo/ │
|
||||
│ server 127 ls ~/ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────────┘
|
Loading…
Reference in New Issue
Block a user