11package git_commands
22
33import (
4+ "fmt"
45 "testing"
6+ "time"
57
68 "github.com/jesseduffield/lazygit/pkg/commands/models"
79 "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
@@ -17,30 +19,38 @@ 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" ,
2328 "" ,
2429 oscommands .NewFakeRunner (t ).
25- ExpectGitArgs ([]string {"stash" , "list" , "-z" , "--pretty=%ct|%gs" }, "" , nil ),
30+ ExpectGitArgs ([]string {"stash" , "list" , "-z" , "--pretty=%H|% ct|%gs" }, "" , nil ),
2631 []* models.StashEntry {},
2732 },
2833 {
2934 "Several stash entries found" ,
3035 "" ,
3136 oscommands .NewFakeRunner (t ).
32- ExpectGitArgs ([]string {"stash" , "list" , "-z" , "--pretty=%ct|%gs" },
33- "WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00 WIP on master: bb86a3f update github template\x00 " ,
34- nil ,
35- ),
37+ ExpectGitArgs ([]string {"stash" , "list" , "-z" , "--pretty=%H|%ct|%gs" },
38+ fmt .Sprintf ("fa1afe1|%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00 deadbeef|%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" ,
47+ Hash : "fa1afe1" ,
4048 },
4149 {
42- Index : 1 ,
43- Name : "WIP on master: bb86a3f update github template" ,
50+ Index : 1 ,
51+ Name : "WIP on master: bb86a3f update github template" ,
52+ Recency : "3d" ,
53+ Hash : "deadbeef" ,
4454 },
4555 },
4656 },
0 commit comments