Add help command

This commit is contained in:
David Dworken
2022-06-05 18:26:02 -07:00
parent 5e44e7ef36
commit ad7e412855
2 changed files with 42 additions and 0 deletions

View File

@ -124,6 +124,7 @@ func TestParameterized(t *testing.T) {
t.Run("testRequestAndReceiveDbDump/"+tester.ShellName(), func(t *testing.T) { testRequestAndReceiveDbDump(t, tester) })
t.Run("testInstallViaPythonScript/"+tester.ShellName(), func(t *testing.T) { testInstallViaPythonScript(t, tester) })
t.Run("testExportWithQuery/"+tester.ShellName(), func(t *testing.T) { testExportWithQuery(t, tester) })
t.Run("testHelpCommand/"+tester.ShellName(), func(t *testing.T) { testHelpCommand(t, tester) })
}
}
@ -1125,4 +1126,20 @@ echo thisisrecorded`)
}
}
func testHelpCommand(t *testing.T, tester shellTester) {
// Setup
defer shared.BackupAndRestore(t)()
installHishtory(t, tester, "")
// Test the help command
out := tester.RunInteractiveShell(t, `hishtory help`)
if !strings.HasPrefix(out, "hishtory: Better shell history\n\nSupported commands:\n") {
t.Fatalf("expected hishtory help to contain intro, actual=%#v", out)
}
out2 := tester.RunInteractiveShell(t, `hishtory -h`)
if out != out2 {
t.Fatalf("expected hishtory -h to equal help")
}
}
// TODO: write a test that runs hishtroy export | grep -v pipefail and then see if that shows up in query/export, I think there is weird behavior here