mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-24 22:11:40 +02:00
Refactor tests to prep for supporting resizing tmux sessions
This commit is contained in:
parent
5f95ac48a4
commit
ebfdaa7a4a
@ -1869,8 +1869,8 @@ func TestTui(t *testing.T) {
|
|||||||
compareGoldens(t, out, "TestTui-InvalidSearch")
|
compareGoldens(t, out, "TestTui-InvalidSearch")
|
||||||
|
|
||||||
// Check the output when the size is smaller
|
// Check the output when the size is smaller
|
||||||
out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []string{
|
out = captureTerminalOutputWithShellNameAndDimensions(t, tester, tester.ShellName(), 100, 20, []TmuxCommand{
|
||||||
"hishtory SPACE tquery ENTER",
|
TmuxCommand{Keys: "hishtory SPACE tquery ENTER"},
|
||||||
})
|
})
|
||||||
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
|
out = strings.TrimSpace(strings.Split(out, "hishtory tquery")[1])
|
||||||
compareGoldens(t, out, "TestTui-SmallTerminal")
|
compareGoldens(t, out, "TestTui-SmallTerminal")
|
||||||
@ -1902,13 +1902,21 @@ func captureTerminalOutput(t *testing.T, tester shellTester, commands []string)
|
|||||||
return captureTerminalOutputWithShellName(t, tester, tester.ShellName(), commands)
|
return captureTerminalOutputWithShellName(t, tester, tester.ShellName(), commands)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TmuxCommand struct {
|
||||||
|
Keys string
|
||||||
|
}
|
||||||
|
|
||||||
func captureTerminalOutputWithShellName(t *testing.T, tester shellTester, overriddenShellName string, commands []string) string {
|
func captureTerminalOutputWithShellName(t *testing.T, tester shellTester, overriddenShellName string, commands []string) string {
|
||||||
return captureTerminalOutputWithShellNameAndDimensions(t, tester, overriddenShellName, 200, 50, commands)
|
sCommands := make([]TmuxCommand, 0)
|
||||||
|
for _, command := range commands {
|
||||||
|
sCommands = append(sCommands, TmuxCommand{Keys: command})
|
||||||
|
}
|
||||||
|
return captureTerminalOutputWithShellNameAndDimensions(t, tester, overriddenShellName, 200, 50, sCommands)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add tests for auto-resizing. They can use the tmux resize-pane command
|
// TODO: add tests for auto-resizing. They can use the tmux resize-pane command
|
||||||
|
|
||||||
func captureTerminalOutputWithShellNameAndDimensions(t *testing.T, tester shellTester, overriddenShellName string, width, height int, commands []string) string {
|
func captureTerminalOutputWithShellNameAndDimensions(t *testing.T, tester shellTester, overriddenShellName string, width, height int, commands []TmuxCommand) string {
|
||||||
sleepAmount := "0.1"
|
sleepAmount := "0.1"
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
sleepAmount = "0.2"
|
sleepAmount = "0.2"
|
||||||
@ -1930,7 +1938,7 @@ func captureTerminalOutputWithShellNameAndDimensions(t *testing.T, tester shellT
|
|||||||
fullCommand += " sleep " + sleepAmount + "\n"
|
fullCommand += " sleep " + sleepAmount + "\n"
|
||||||
for _, cmd := range commands {
|
for _, cmd := range commands {
|
||||||
fullCommand += " tmux send -t foo -- "
|
fullCommand += " tmux send -t foo -- "
|
||||||
fullCommand += cmd
|
fullCommand += cmd.Keys
|
||||||
fullCommand += "\n"
|
fullCommand += "\n"
|
||||||
fullCommand += " sleep " + sleepAmount + "\n"
|
fullCommand += " sleep " + sleepAmount + "\n"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user