summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/stash_loader_test.go
diff options
context:
space:
mode:
authorsudoburt <sudoburt@proton.me>2022-11-10 21:19:29 -0500
committerJesse Duffield <jessedduffield@gmail.com>2022-11-14 18:11:45 +1100
commit3e73dacce3365b540b278c3e1afb9bd8059d1ce7 (patch)
treed2706dc236491f7839ff5119e4eb60409e5bdbd8 /pkg/commands/git_commands/stash_loader_test.go
parentf67824b349fdbdcd1779e260f80bd26a446a4702 (diff)
Merge loaders package into git_commands package
Diffstat (limited to 'pkg/commands/git_commands/stash_loader_test.go')
-rw-r--r--pkg/commands/git_commands/stash_loader_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/stash_loader_test.go b/pkg/commands/git_commands/stash_loader_test.go
new file mode 100644
index 000000000..2e2180fba
--- /dev/null
+++ b/pkg/commands/git_commands/stash_loader_test.go
@@ -0,0 +1,60 @@
+package git_commands
+
+import (
+ "testing"
+
+ "github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
+ "github.com/jesseduffield/lazygit/pkg/utils"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestGetStashEntries(t *testing.T) {
+ type scenario struct {
+ testName string
+ filterPath string
+ runner oscommands.ICmdObjRunner
+ expectedStashEntries []*models.StashEntry
+ }
+
+ scenarios := []scenario{
+ {
+ "No stash entries found",
+ "",
+ oscommands.NewFakeRunner(t).
+ Expect(`git stash list -z --pretty='%gs'`, "", nil),
+ []*models.StashEntry{},
+ },
+ {
+ "Several stash entries found",
+ "",
+ oscommands.NewFakeRunner(t).
+ Expect(
+ `git stash list -z --pretty='%gs'`,
+ "WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00WIP on master: bb86a3f update github template\x00",
+ nil,
+ ),
+ []*models.StashEntry{
+ {
+ Index: 0,
+ Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
+ },
+ {
+ Index: 1,
+ Name: "WIP on master: bb86a3f update github template",
+ },
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
+
+ loader := NewStashLoader(utils.NewDummyCommon(), cmd)
+
+ assert.EqualValues(t, s.expectedStashEntries, loader.GetStashEntries(s.filterPath))
+ })
+ }
+}