1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-09-16 09:16:26 +02:00

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.
This commit is contained in:
Stefan Haller
2025-08-25 19:05:18 +02:00
parent 5a6de1248f
commit 61d5b1646d

View File

@@ -1,7 +1,9 @@
package git_commands package git_commands
import ( import (
"fmt"
"testing" "testing"
"time"
"github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
@@ -17,6 +19,9 @@ func TestGetStashEntries(t *testing.T) {
expectedStashEntries []*models.StashEntry expectedStashEntries []*models.StashEntry
} }
hoursAgo := time.Now().Unix() - 3*3600 - 1800
daysAgo := time.Now().Unix() - 3*3600*24 - 3600*12
scenarios := []scenario{ scenarios := []scenario{
{ {
"No stash entries found", "No stash entries found",
@@ -30,17 +35,20 @@ func TestGetStashEntries(t *testing.T) {
"", "",
oscommands.NewFakeRunner(t). oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"}, 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", fmt.Sprintf("%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00%d|WIP on master: bb86a3f update github template\x00",
nil, hoursAgo,
), daysAgo,
), nil),
[]*models.StashEntry{ []*models.StashEntry{
{ {
Index: 0, Index: 0,
Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build", Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
Recency: "3h",
}, },
{ {
Index: 1, Index: 1,
Name: "WIP on master: bb86a3f update github template", Name: "WIP on master: bb86a3f update github template",
Recency: "3d",
}, },
}, },
}, },