MCPcopy
hub / github.com/ddworken/hishtory / testRepeatedEnableDisable

Function testRepeatedEnableDisable

client/integration_test.go:704–733  ·  view source on GitHub ↗
(t *testing.T, tester shellTester)

Source from the content-addressed store, hash-verified

702}
703
704func testRepeatedEnableDisable(t *testing.T, tester shellTester) {
705 // Set up
706 defer testutils.BackupAndRestore(t)()
707 installHishtory(t, tester, "")
708
709 // Run a command many times
710 for i := 0; i < 25; i++ {
711 tester.RunInteractiveShell(t, fmt.Sprintf(`echo mycommand-%d
712 hishtory disable
713echo shouldnotshowup
714sleep 0.5
715hishtory enable`, i))
716 out := hishtoryQuery(t, tester, fmt.Sprintf("mycommand-%d", i))
717 if strings.Count(out, "\n") != 3 {
718 t.Fatalf("hishtory query #%d has the wrong number of lines=%d, out=%#v", i, strings.Count(out, "\n"), out)
719 }
720 if strings.Count(out, "echo mycommand") != 1 {
721 t.Fatalf("hishtory query #%d has the wrong number of commands=%d, out=%#v", i, strings.Count(out, "echo mycommand"), out)
722 }
723 require.Contains(t, out, "hishtory query mycommand-")
724 out = hishtoryQuery(t, tester, "")
725 require.NotContains(t, out, "shouldnotshowup")
726 }
727
728 out := tester.RunInteractiveShell(t, "hishtory export | grep -v pipefail | grep -v '/tmp/client install'")
729 expectedOutput := "echo mycommand-0\nhishtory enable\nhishtory query mycommand-0\nhishtory query\necho mycommand-1\nhishtory enable\nhishtory query mycommand-1\nhishtory query\necho mycommand-2\nhishtory enable\nhishtory query mycommand-2\nhishtory query\necho mycommand-3\nhishtory enable\nhishtory query mycommand-3\nhishtory query\necho mycommand-4\nhishtory enable\nhishtory query mycommand-4\nhishtory query\necho mycommand-5\nhishtory enable\nhishtory query mycommand-5\nhishtory query\necho mycommand-6\nhishtory enable\nhishtory query mycommand-6\nhishtory query\necho mycommand-7\nhishtory enable\nhishtory query mycommand-7\nhishtory query\necho mycommand-8\nhishtory enable\nhishtory query mycommand-8\nhishtory query\necho mycommand-9\nhishtory enable\nhishtory query mycommand-9\nhishtory query\necho mycommand-10\nhishtory enable\nhishtory query mycommand-10\nhishtory query\necho mycommand-11\nhishtory enable\nhishtory query mycommand-11\nhishtory query\necho mycommand-12\nhishtory enable\nhishtory query mycommand-12\nhishtory query\necho mycommand-13\nhishtory enable\nhishtory query mycommand-13\nhishtory query\necho mycommand-14\nhishtory enable\nhishtory query mycommand-14\nhishtory query\necho mycommand-15\nhishtory enable\nhishtory query mycommand-15\nhishtory query\necho mycommand-16\nhishtory enable\nhishtory query mycommand-16\nhishtory query\necho mycommand-17\nhishtory enable\nhishtory query mycommand-17\nhishtory query\necho mycommand-18\nhishtory enable\nhishtory query mycommand-18\nhishtory query\necho mycommand-19\nhishtory enable\nhishtory query mycommand-19\nhishtory query\necho mycommand-20\nhishtory enable\nhishtory query mycommand-20\nhishtory query\necho mycommand-21\nhishtory enable\nhishtory query mycommand-21\nhishtory query\necho mycommand-22\nhishtory enable\nhishtory query mycommand-22\nhishtory query\necho mycommand-23\nhishtory enable\nhishtory query mycommand-23\nhishtory query\necho mycommand-24\nhishtory enable\nhishtory query mycommand-24\nhishtory query\n"
730 if diff := cmp.Diff(expectedOutput, out); diff != "" {
731 t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
732 }
733}
734
735func testExcludeHiddenCommand(t *testing.T, tester shellTester) {
736 // Set up

Callers 1

TestParamFunction · 0.85

Calls 4

BackupAndRestoreFunction · 0.92
installHishtoryFunction · 0.85
hishtoryQueryFunction · 0.85
RunInteractiveShellMethod · 0.65

Tested by

no test coverage detected