(t *testing.T)
| 2764 | } |
| 2765 | |
| 2766 | func TestTimestampFormat(t *testing.T) { |
| 2767 | // Setup |
| 2768 | markTestForSharding(t, 6) |
| 2769 | tester := zshTester{} |
| 2770 | defer testutils.BackupAndRestore(t)() |
| 2771 | userSecret := installHishtory(t, tester, "") |
| 2772 | |
| 2773 | // Add an entry just to ensure we get consistent table sizing |
| 2774 | tester.RunInteractiveShell(t, "echo tablesizing") |
| 2775 | |
| 2776 | // Add some entries with fixed timestamps |
| 2777 | tmz, err := time.LoadLocation("America/Los_Angeles") |
| 2778 | require.NoError(t, err) |
| 2779 | entry1 := testutils.MakeFakeHistoryEntry("table_cmd1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") |
| 2780 | entry1.StartTime = time.Unix(1650096186, 0).In(tmz) |
| 2781 | entry1.EndTime = time.Unix(1650096190, 0).In(tmz) |
| 2782 | manuallySubmitHistoryEntry(t, userSecret, entry1) |
| 2783 | entry2 := testutils.MakeFakeHistoryEntry("table_cmd2") |
| 2784 | entry2.StartTime = time.Unix(1650096196, 0).In(tmz) |
| 2785 | entry2.EndTime = time.Unix(1650096220, 0).In(tmz) |
| 2786 | entry2.CurrentWorkingDirectory = "~/foo/" |
| 2787 | entry2.ExitCode = 3 |
| 2788 | manuallySubmitHistoryEntry(t, userSecret, entry2) |
| 2789 | |
| 2790 | // Check the init the timestamp format |
| 2791 | require.Equal(t, "Jan 2 2006 15:04:05 MST", strings.TrimSpace(tester.RunInteractiveShell(t, ` hishtory config-get timestamp-format`))) |
| 2792 | |
| 2793 | // Set a custom timestamp format |
| 2794 | tester.RunInteractiveShell(t, ` hishtory config-set timestamp-format '2006/Jan/2 15:04'`) |
| 2795 | |
| 2796 | // And check that it is displayed in both the tui and the classic view |
| 2797 | out := hishtoryQuery(t, tester, "-pipefail -tablesizing") |
| 2798 | testutils.CompareGoldens(t, out, "TestTimestampFormat-query") |
| 2799 | out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery ENTER", "table_cmd SPACE -tquery"}) |
| 2800 | out = stripRequiredPrefix(t, out, "hishtory tquery") |
| 2801 | testutils.CompareGoldens(t, out, "TestTimestampFormat-tquery") |
| 2802 | } |
| 2803 | |
| 2804 | func TestSortByConsistentTimezone(t *testing.T) { |
| 2805 | // Setup |
nothing calls this directly
no test coverage detected