Skip to content

Commit 61d5b16

Browse files
committed
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.
1 parent 5a6de12 commit 61d5b16

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

pkg/commands/git_commands/stash_loader_test.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package git_commands
22

33
import (
4+
"fmt"
45
"testing"
6+
"time"
57

68
"github.com/jesseduffield/lazygit/pkg/commands/models"
79
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
@@ -17,6 +19,9 @@ func TestGetStashEntries(t *testing.T) {
1719
expectedStashEntries []*models.StashEntry
1820
}
1921

22+
hoursAgo := time.Now().Unix() - 3*3600 - 1800
23+
daysAgo := time.Now().Unix() - 3*3600*24 - 3600*12
24+
2025
scenarios := []scenario{
2126
{
2227
"No stash entries found",
@@ -30,17 +35,20 @@ func TestGetStashEntries(t *testing.T) {
3035
"",
3136
oscommands.NewFakeRunner(t).
3237
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"},
33-
"WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00WIP on master: bb86a3f update github template\x00",
34-
nil,
35-
),
38+
fmt.Sprintf("%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00%d|WIP on master: bb86a3f update github template\x00",
39+
hoursAgo,
40+
daysAgo,
41+
), nil),
3642
[]*models.StashEntry{
3743
{
38-
Index: 0,
39-
Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
44+
Index: 0,
45+
Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
46+
Recency: "3h",
4047
},
4148
{
42-
Index: 1,
43-
Name: "WIP on master: bb86a3f update github template",
49+
Index: 1,
50+
Name: "WIP on master: bb86a3f update github template",
51+
Recency: "3d",
4452
},
4553
},
4654
},

0 commit comments

Comments
 (0)