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

Function testExcludeHiddenCommand

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

Source from the content-addressed store, hash-verified

733}
734
735func testExcludeHiddenCommand(t *testing.T, tester shellTester) {
736 // Set up
737 defer testutils.BackupAndRestore(t)()
738 installHishtory(t, tester, "")
739
740 tester.RunInteractiveShell(t, `echo hello1
741 echo hidden
742echo hello2
743 echo hidden`)
744 tester.RunInteractiveShell(t, " echo hidden")
745 out := hishtoryQuery(t, tester, "-pipefail")
746 if strings.Count(out, "\n") != 3 {
747 t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v, bash hishtory file=%#v", strings.Count(out, "\n"), out, tester.RunInteractiveShell(t, "cat ~/.bash_history"))
748 }
749 if strings.Count(out, "echo hello") != 2 {
750 t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out)
751 }
752 if strings.Count(out, "echo hello1") != 1 {
753 t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out)
754 }
755 if strings.Count(out, "echo hello2") != 1 {
756 t.Fatalf("hishtory query has the wrong number of commands=%d, out=%#v", strings.Count(out, "echo mycommand"), out)
757 }
758 require.NotContains(t, out, "hidden")
759
760 out = tester.RunInteractiveShell(t, "hishtory export | grep -v pipefail | grep -v '/tmp/client install'")
761 expectedOutput := "echo hello1\necho hello2\n"
762 if out != expectedOutput {
763 t.Fatalf("hishtory export has unexpected output=%#v", out)
764 }
765}
766
767func waitForBackgroundSavesToComplete(t testing.TB) {
768 lastOut := ""

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