Add a test for multi-line history entries

This commit is contained in:
David Dworken 2022-10-27 22:02:19 -07:00
parent f9098d87d5
commit 043e815716
3 changed files with 15 additions and 4 deletions

View File

@ -148,7 +148,6 @@ func TestParameterized(t *testing.T) {
t.Run("testConfigGetSet/"+tester.ShellName(), func(t *testing.T) { testConfigGetSet(t, tester) })
t.Run("testControlR/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName()) })
t.Run("testHandleUpgradedFeatures/"+tester.ShellName(), func(t *testing.T) { testHandleUpgradedFeatures(t, tester) })
// TODO: Add a test for multi-line history entries
}
t.Run("testControlR/fish", func(t *testing.T) { testControlR(t, bashTester{}, "fish") })
}
@ -1004,16 +1003,20 @@ func testDisplayTable(t *testing.T, tester shellTester) {
compareGoldens(t, out, "testDisplayTable-customColumns")
// And again
tester.RunInteractiveShell(t, ` hishtory disable`)
tester.RunInteractiveShell(t, `hishtory config-set displayed-columns Hostname 'Exit Code' Command`)
out = hishtoryQuery(t, tester, "table")
compareGoldens(t, out, "testDisplayTable-customColumns-2")
// And again
tester.RunInteractiveShell(t, ` hishtory disable`)
tester.RunInteractiveShell(t, `hishtory config-add displayed-columns CWD`)
out = hishtoryQuery(t, tester, "table")
compareGoldens(t, out, "testDisplayTable-customColumns-3")
// Test displaying a command with multiple lines
entry3 := testutils.MakeFakeHistoryEntry("while :\ndo\nls /table/\ndone")
manuallySubmitHistoryEntry(t, userSecret, entry3)
out = hishtoryQuery(t, tester, "table")
compareGoldens(t, out, "testDisplayTable-customColumns-multiLineCommand")
}
func testRequestAndReceiveDbDump(t *testing.T, tester shellTester) {

View File

@ -1,4 +1,4 @@
caHostname Exit Code Command CWD
Hostname Exit Code Command CWD
Davids-MacBook-Air.local 0 hishtory query table ~/code/hishtory
localhost 3 table_cmd2 ~/foo/
localhost 2 table_cmd1 /tmp/

View File

@ -0,0 +1,8 @@
Hostname Exit Code Command CWD
Davids-MacBook-Air.local 0 hishtory query table ~/code/hishtory
localhost 2 while : /tmp/
do
ls /table/
done
localhost 3 table_cmd2 ~/foo/
localhost 2 table_cmd1 /tmp/