Prompt people if they run hishtory init and already have a bunch of entries + fix tests + add TODOs + add hishtory version to requests

This commit is contained in:
David Dworken
2022-10-01 09:50:06 -07:00
parent 4f94698ca6
commit 757ebb9547
5 changed files with 38 additions and 7 deletions

View File

@ -203,7 +203,8 @@ func testIntegrationWithNewDevice(t *testing.T, tester shellTester) {
}
// Set the secret key to the previous secret key
out = tester.RunInteractiveShell(t, `hishtory init `+userSecret)
out, err := tester.RunInteractiveShellRelaxed(t, `yes | hishtory init `+userSecret)
shared.Check(t, err)
if !strings.Contains(out, "Setting secret hishtory key to "+userSecret) {
t.Fatalf("Failed to re-init with the user secret: %v", out)
}
@ -249,7 +250,7 @@ func testIntegrationWithNewDevice(t *testing.T, tester shellTester) {
if strings.Contains(out, "thisisnotrecorded") {
t.Fatalf("hishtory export contains a command that should not have been recorded, out=%#v", out)
}
expectedOutputWithoutKey := "hishtory status\nhishtory query\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory enable\necho thisisrecorded\nhishtory query\nhishtory query foo\necho hello | grep complex | sed s/h/i/g; echo baz && echo \"fo 'o\"\nhishtory query complex\nhishtory query\necho mynewcommand\nhishtory query\nhishtory init %s\nhishtory query\necho mynewercommand\nhishtory query\nothercomputer\nhishtory query\n"
expectedOutputWithoutKey := "hishtory status\nhishtory query\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory enable\necho thisisrecorded\nhishtory query\nhishtory query foo\necho hello | grep complex | sed s/h/i/g; echo baz && echo \"fo 'o\"\nhishtory query complex\nhishtory query\necho mynewcommand\nhishtory query\nyes | hishtory init %s\nhishtory query\necho mynewercommand\nhishtory query\nothercomputer\nhishtory query\n"
expectedOutput := fmt.Sprintf(expectedOutputWithoutKey, userSecret)
if diff := cmp.Diff(expectedOutput, out); diff != "" {
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)