mirror of
https://github.com/ddworken/hishtory.git
synced 2025-03-11 05:38:11 +01:00
Add a timestamp test that I believe will fail for macos
This commit is contained in:
parent
3553897101
commit
38b91f933c
@ -121,6 +121,7 @@ func TestParameterized(t *testing.T) {
|
||||
t.Run("testIntegrationWithNewDevice/"+tester.ShellName(), func(t *testing.T) { testIntegrationWithNewDevice(t, tester) })
|
||||
t.Run("testHishtoryBackgroundSaving/"+tester.ShellName(), func(t *testing.T) { testHishtoryBackgroundSaving(t, tester) })
|
||||
t.Run("testDisplayTable/"+tester.ShellName(), func(t *testing.T) { testDisplayTable(t, tester) })
|
||||
t.Run("testTimestampsAreReasonablyCorrect/"+tester.ShellName(), func(t *testing.T) { testTimestampsAreReasonablyCorrect(t, tester) })
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,6 +751,28 @@ func manuallySubmitHistoryEntry(t *testing.T, userSecret string, entry data.Hist
|
||||
}
|
||||
}
|
||||
|
||||
func testTimestampsAreReasonablyCorrect(t *testing.T, tester shellTester) {
|
||||
// Setup
|
||||
defer shared.BackupAndRestore(t)()
|
||||
installHishtory(t, tester, "")
|
||||
|
||||
// Record a command
|
||||
out := tester.RunInteractiveShell(t, "echo hello")
|
||||
if out != "hello\n" {
|
||||
t.Fatalf("running echo hello had unexpected out=%#v", out)
|
||||
}
|
||||
|
||||
// Query for it and check that the timestamp that gets recorded looks reasonable
|
||||
out = hishtoryQuery(t, tester, "echo hello")
|
||||
if strings.Count(out, "\n") != 2 {
|
||||
t.Fatalf("hishtory query has unexpected number of lines: out=%#v", out)
|
||||
}
|
||||
expectedDate := time.Now().Format("Jan 2 2006")
|
||||
if !strings.Contains(out, expectedDate) {
|
||||
t.Fatalf("hishtory query has an incorrect date: out=%#v", out)
|
||||
}
|
||||
}
|
||||
|
||||
func testHishtoryBackgroundSaving(t *testing.T, tester shellTester) {
|
||||
// Setup
|
||||
defer shared.BackupAndRestore(t)()
|
||||
|
Loading…
Reference in New Issue
Block a user