working tracking for start time

This commit is contained in:
David Dworken
2022-01-09 16:39:13 -08:00
parent 11962b26c9
commit 3cc9118a69
9 changed files with 83 additions and 32 deletions

View File

@ -5,6 +5,7 @@ import (
"path"
"strings"
"testing"
"time"
)
func TestSetup(t *testing.T) {
@ -28,7 +29,7 @@ func TestSetup(t *testing.T) {
func TestBuildHistoryEntry(t *testing.T) {
defer BackupAndRestore(t)
Check(t, Setup([]string{}))
entry, err := BuildHistoryEntry([]string{"unused", "saveHistoryEntry", "120", " 123 ls / "})
entry, err := BuildHistoryEntry([]string{"unused", "saveHistoryEntry", "120", " 123 ls / ", "1641774958326745663"})
Check(t, err)
if entry.UserSecret == "" || len(entry.UserSecret) < 10 || strings.TrimSpace(entry.UserSecret) != entry.UserSecret {
t.Fatalf("history entry has unexpected user secret: %v", entry.UserSecret)
@ -45,6 +46,9 @@ func TestBuildHistoryEntry(t *testing.T) {
if entry.Command != "ls /" {
t.Fatalf("history entry has unexpected command: %v", entry.Command)
}
if entry.StartTime.Format(time.RFC3339) != "2022-01-09T16:35:58-08:00" {
t.Fatalf("history entry has incorrect start time: %v", entry.StartTime.Format(time.RFC3339))
}
}
func TestGetUserSecret(t *testing.T) {