From 61d5b1646d518f1ae41d63706fb057cd890b93c5 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 25 Aug 2025 19:05:18 +0200 Subject: [PATCH] Cleanup: bring stash loader test up to date It didn't actually test how it parses the unix time stamps, and the test only succeeded because the code is lenient against it missing. --- .../git_commands/stash_loader_test.go | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/commands/git_commands/stash_loader_test.go b/pkg/commands/git_commands/stash_loader_test.go index 99e6a57d2..3b0bf3eea 100644 --- a/pkg/commands/git_commands/stash_loader_test.go +++ b/pkg/commands/git_commands/stash_loader_test.go @@ -1,7 +1,9 @@ package git_commands import ( + "fmt" "testing" + "time" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" @@ -17,6 +19,9 @@ func TestGetStashEntries(t *testing.T) { expectedStashEntries []*models.StashEntry } + hoursAgo := time.Now().Unix() - 3*3600 - 1800 + daysAgo := time.Now().Unix() - 3*3600*24 - 3600*12 + scenarios := []scenario{ { "No stash entries found", @@ -30,17 +35,20 @@ func TestGetStashEntries(t *testing.T) { "", oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"}, - "WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00WIP on master: bb86a3f update github template\x00", - nil, - ), + fmt.Sprintf("%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00%d|WIP on master: bb86a3f update github template\x00", + hoursAgo, + daysAgo, + ), nil), []*models.StashEntry{ { - Index: 0, - Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build", + Index: 0, + Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build", + Recency: "3h", }, { - Index: 1, - Name: "WIP on master: bb86a3f update github template", + Index: 1, + Name: "WIP on master: bb86a3f update github template", + Recency: "3d", }, }, },