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

Function testRepeatedCommandAndQuery

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

Source from the content-addressed store, hash-verified

677}
678
679func testRepeatedCommandAndQuery(t *testing.T, tester shellTester) {
680 // Set up
681 defer testutils.BackupAndRestore(t)()
682 userSecret := installHishtory(t, tester, "")
683
684 // Check the status command
685 out := tester.RunInteractiveShell(t, `hishtory status`)
686 if out != fmt.Sprintf("hiSHtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
687 t.Fatalf("status command has unexpected output: %#v", out)
688 }
689
690 // Run a command many times
691 for i := 0; i < 25; i++ {
692 tester.RunInteractiveShell(t, fmt.Sprintf("echo mycommand-%d", i))
693 out = hishtoryQuery(t, tester, fmt.Sprintf("mycommand-%d", i))
694 if strings.Count(out, "\n") != 3 {
695 t.Fatalf("hishtory query #%d has the wrong number of lines=%d, out=%#v", i, strings.Count(out, "\n"), out)
696 }
697 if strings.Count(out, "echo mycommand") != 1 {
698 t.Fatalf("hishtory query #%d has the wrong number of commands=%d, out=%#v", i, strings.Count(out, "echo mycommand"), out)
699 }
700 require.Contains(t, out, "hishtory query mycommand-")
701 }
702}
703
704func testRepeatedEnableDisable(t *testing.T, tester shellTester) {
705 // 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