mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-18 03:20:53 +01:00
Fix more tests for presaving
This commit is contained in:
parent
223bb1754d
commit
a99747602e
@ -128,10 +128,8 @@ func testIntegrationWithNewDevice(t *testing.T, tester shellTester) {
|
|||||||
// Run the test
|
// Run the test
|
||||||
userSecret := testBasicUserFlow(t, tester, Online)
|
userSecret := testBasicUserFlow(t, tester, Online)
|
||||||
|
|
||||||
// Clear all local state
|
|
||||||
testutils.ResetLocalState(t)
|
|
||||||
|
|
||||||
// Install it again
|
// Install it again
|
||||||
|
testutils.ResetLocalState(t)
|
||||||
installHishtory(t, tester, userSecret)
|
installHishtory(t, tester, userSecret)
|
||||||
|
|
||||||
// Querying should show the history from the previous run
|
// Querying should show the history from the previous run
|
||||||
@ -151,16 +149,16 @@ func testIntegrationWithNewDevice(t *testing.T, tester shellTester) {
|
|||||||
t.Fatalf("output has `echo mynewcommand` the wrong number of times")
|
t.Fatalf("output has `echo mynewcommand` the wrong number of times")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear local state again
|
|
||||||
testutils.ResetLocalState(t)
|
|
||||||
|
|
||||||
// Install it a 3rd time
|
// Install it a 3rd time
|
||||||
|
testutils.ResetLocalState(t)
|
||||||
installHishtory(t, tester, "adifferentsecret")
|
installHishtory(t, tester, "adifferentsecret")
|
||||||
|
|
||||||
// Run a command that shouldn't be in the hishtory later on
|
// Run a command that shouldn't be in the hishtory later on
|
||||||
tester.RunInteractiveShell(t, `echo notinthehistory`)
|
tester.RunInteractiveShell(t, `echo notinthehistory`)
|
||||||
out = hishtoryQuery(t, tester, "")
|
out = hishtoryQuery(t, tester, "")
|
||||||
require.Contains(t, out, "echo notinthehistory")
|
require.Contains(t, out, "echo notinthehistory")
|
||||||
|
require.NotContains(t, out, "mynewcommand")
|
||||||
|
require.NotContains(t, out, "thisisrecorded")
|
||||||
|
|
||||||
// Set the secret key to the previous secret key
|
// Set the secret key to the previous secret key
|
||||||
out, err := tester.RunInteractiveShellRelaxed(t, ` export HISHTORY_SKIP_INIT_IMPORT=1
|
out, err := tester.RunInteractiveShellRelaxed(t, ` export HISHTORY_SKIP_INIT_IMPORT=1
|
||||||
@ -206,7 +204,7 @@ yes | hishtory init `+userSecret)
|
|||||||
// Finally, test the export command
|
// Finally, test the export command
|
||||||
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail | grep -v '/tmp/client install'`)
|
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail | grep -v '/tmp/client install'`)
|
||||||
require.NotContains(t, out, "thisisnotrecorded", "hishtory export contains a command that should not have been recorded")
|
require.NotContains(t, out, "thisisnotrecorded", "hishtory export contains a command that should not have been recorded")
|
||||||
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\" # mycommand\nhishtory query complex\nhishtory query\necho mynewcommand\nhishtory query\nyes | hishtory init %s\nhishtory query\necho mynewercommand\nhishtory query\nothercomputer\nhishtory query\nhishtory reupload\n"
|
expectedOutputWithoutKey := "hishtory status\nhishtory query\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory disable\nhishtory enable\necho thisisrecorded\nhishtory query\nhishtory query foo\necho hello | grep complex | sed s/h/i/g; echo baz && echo \"fo 'o\" # mycommand\nhishtory query complex\nhishtory query\necho mynewcommand\nhishtory query\nyes | hishtory init %s\nhishtory query\necho mynewercommand\nhishtory query\nothercomputer\nhishtory query\nhishtory reupload\n"
|
||||||
expectedOutput := fmt.Sprintf(expectedOutputWithoutKey, userSecret)
|
expectedOutput := fmt.Sprintf(expectedOutputWithoutKey, userSecret)
|
||||||
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||||
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
||||||
@ -2625,3 +2623,4 @@ func TestAugmentedIsOfflineError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: somehow test/confirm that hishtory works even if only bash/only zsh is installed
|
// TODO: somehow test/confirm that hishtory works even if only bash/only zsh is installed
|
||||||
|
// TODO: Tests for deleting presaved entries while offline
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
CWD Hostname Exit Code Command
|
CWD Hostname Exit Code Command
|
||||||
/ ghaction-runner-hostname 0 hishtory config-set displayed-columns CWD Hostname 'Exit Code' Command
|
/ ghaction-runner-hostname 0 hishtory config-set displayed-columns CWD Hostname 'Exit Code' Command
|
||||||
/ ghaction-runner-hostname 0 exit
|
/ ghaction-runner-hostname 0 exit
|
||||||
/ ghaction-runner-hostname 0 echo foo
|
/ ghaction-runner-hostname 0 echo foo
|
||||||
/ ghaction-runner-hostname 0 fish
|
/ ghaction-runner-hostname 0 fish
|
||||||
/ ghaction-runner-hostname 0 ls /tmp/ &
|
/ ghaction-runner-hostname 0 ls /tmp/ &
|
||||||
/ ghaction-runner-hostname 0 echo "foo"
|
/ ghaction-runner-hostname 0 echo "foo"
|
||||||
/ ghaction-runner-hostname 0 echo bar
|
/ ghaction-runner-hostname 0 echo bar
|
||||||
/ ghaction-runner-hostname 0 echo foo
|
/ ghaction-runner-hostname 0 echo foo
|
||||||
|
@ -5,6 +5,7 @@ ls /bar
|
|||||||
ls /foo
|
ls /foo
|
||||||
echo foo
|
echo foo
|
||||||
echo bar
|
echo bar
|
||||||
|
hishtory disable
|
||||||
hishtory enable
|
hishtory enable
|
||||||
echo thisisrecorded
|
echo thisisrecorded
|
||||||
hishtory query
|
hishtory query
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Hostname Exit Code Command
|
Hostname Exit Code Command
|
||||||
ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command
|
ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command
|
||||||
ghaction-runner-hostname 0 hishtory reupload
|
ghaction-runner-hostname 0 hishtory reupload
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
localhost 2 othercomputer
|
localhost 2 othercomputer
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
ghaction-runner-hostname 0 echo mynewercommand
|
ghaction-runner-hostname 0 echo mynewercommand
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
@ -15,6 +15,7 @@ ghaction-runner-hostname 0 hishtory query foo
|
|||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
ghaction-runner-hostname 0 echo thisisrecorded
|
ghaction-runner-hostname 0 echo thisisrecorded
|
||||||
ghaction-runner-hostname 0 hishtory enable
|
ghaction-runner-hostname 0 hishtory enable
|
||||||
|
ghaction-runner-hostname 0 hishtory disable
|
||||||
ghaction-runner-hostname 0 echo bar
|
ghaction-runner-hostname 0 echo bar
|
||||||
ghaction-runner-hostname 0 echo foo
|
ghaction-runner-hostname 0 echo foo
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Hostname Exit Code Command
|
Hostname Exit Code Command
|
||||||
ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command
|
ghaction-runner-hostname 0 hishtory config-set displayed-columns Hostname 'Exit Code' Command
|
||||||
ghaction-runner-hostname 0 hishtory reupload
|
ghaction-runner-hostname 0 hishtory reupload
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
localhost 2 othercomputer
|
localhost 2 othercomputer
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
ghaction-runner-hostname 0 echo mynewercommand
|
ghaction-runner-hostname 0 echo mynewercommand
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
@ -15,6 +15,7 @@ ghaction-runner-hostname 0 hishtory query foo
|
|||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
ghaction-runner-hostname 0 echo thisisrecorded
|
ghaction-runner-hostname 0 echo thisisrecorded
|
||||||
ghaction-runner-hostname 0 hishtory enable
|
ghaction-runner-hostname 0 hishtory enable
|
||||||
|
ghaction-runner-hostname 0 hishtory disable
|
||||||
ghaction-runner-hostname 0 echo bar
|
ghaction-runner-hostname 0 echo bar
|
||||||
ghaction-runner-hostname 0 echo foo
|
ghaction-runner-hostname 0 echo foo
|
||||||
ghaction-runner-hostname 0 hishtory query
|
ghaction-runner-hostname 0 hishtory query
|
||||||
|
@ -5,6 +5,7 @@ ls /bar
|
|||||||
ls /foo
|
ls /foo
|
||||||
echo foo
|
echo foo
|
||||||
echo bar
|
echo bar
|
||||||
|
hishtory disable
|
||||||
hishtory enable
|
hishtory enable
|
||||||
echo thisisrecorded
|
echo thisisrecorded
|
||||||
hishtory query
|
hishtory query
|
||||||
|
Loading…
Reference in New Issue
Block a user