(t *testing.T, tester shellTester)
| 677 | } |
| 678 | |
| 679 | func 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 | |
| 704 | func testRepeatedEnableDisable(t *testing.T, tester shellTester) { |
| 705 | // Set up |
no test coverage detected