From e78e829e3a8940f5b7b8f0bfc77b3316d19e1e8b Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Sat, 15 Oct 2022 11:57:19 +0900 Subject: [PATCH] test: add an integration test for rename stash --- pkg/integration/components/shell.go | 5 +++ pkg/integration/tests/stash/rename.go | 33 ++++++++++++++++++ pkg/integration/tests/tests.go | 2 ++ .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../rename/expected/repo/.git_keep/FETCH_HEAD | 0 .../stash/rename/expected/repo/.git_keep/HEAD | 1 + .../rename/expected/repo/.git_keep/ORIG_HEAD | 1 + .../repo/.git_keep/commit-template.txt | 0 .../rename/expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../rename/expected/repo/.git_keep/index | Bin 0 -> 65 bytes .../expected/repo/.git_keep/info/exclude | 0 .../rename/expected/repo/.git_keep/logs/HEAD | 2 ++ .../repo/.git_keep/logs/refs/heads/master | 1 + .../expected/repo/.git_keep/logs/refs/stash | 1 + .../25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 | Bin 0 -> 31 bytes .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 0 -> 15 bytes .../4d/ff185ecddfb638f76215fa07adde0f4e97da7c | 2 ++ .../8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf | 2 ++ .../c6/f35659c0cf57c794d79df88283d7ee933831dd | Bin 0 -> 181 bytes .../fc/66bff0a9fdfe660b6e490dc217a9c26ffc5fff | Bin 0 -> 48 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../rename/expected/repo/.git_keep/refs/stash | 1 + 23 files changed, 66 insertions(+) create mode 100644 pkg/integration/tests/stash/rename.go create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/commit-template.txt create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/config create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/description create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/index create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/objects/25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/objects/4d/ff185ecddfb638f76215fa07adde0f4e97da7c create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/objects/c6/f35659c0cf57c794d79df88283d7ee933831dd create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/objects/fc/66bff0a9fdfe660b6e490dc217a9c26ffc5fff create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/stash/rename/expected/repo/.git_keep/refs/stash diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 5f7fef350..1d8182edb 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -111,3 +111,8 @@ func (s *Shell) CreateNCommits(n int) *Shell { return s } + +func (s *Shell) StashWithMessage(message string) *Shell { + s.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message)) + return s +} diff --git a/pkg/integration/tests/stash/rename.go b/pkg/integration/tests/stash/rename.go new file mode 100644 index 000000000..97cfae006 --- /dev/null +++ b/pkg/integration/tests/stash/rename.go @@ -0,0 +1,33 @@ +package stash + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Rename = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Try to rename the stash.", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("blah"). + CreateFileAndAdd("foo", "change to stash"). + StashWithMessage("bar") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + input.SwitchToStashWindow() + assert.CurrentViewName("stash") + + assert.MatchSelectedLine(Equals("On master: bar")) + input.PressKeys(keys.Stash.RenameStash) + assert.InPrompt() + assert.MatchCurrentViewTitle(Equals("Rename stash: stash@{0}")) + + input.Type(" baz") + input.Confirm() + + assert.MatchSelectedLine(Equals("On master: bar baz")) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 21f06a376..6b4583e6d 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -16,6 +16,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/integration/tests/commit" "github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands" "github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase" + "github.com/jesseduffield/lazygit/pkg/integration/tests/stash" ) // Here is where we lists the actual tests that will run. When you create a new test, @@ -38,6 +39,7 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPick, cherry_pick.CherryPickConflicts, custom_commands.FormPrompts, + stash.Rename, } func GetTests() []*components.IntegrationTest { diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..907b30816 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +blah diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD new file mode 100644 index 000000000..4db7189cb --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD @@ -0,0 +1 @@ +8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/commit-template.txt b/test/integration_new/stash/rename/expected/repo/.git_keep/commit-template.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/config b/test/integration_new/stash/rename/expected/repo/.git_keep/config new file mode 100644 index 000000000..8a748ce32 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/description b/test/integration_new/stash/rename/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/index b/test/integration_new/stash/rename/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..65d675154f23ffb2d0196e017d44a5e7017550f5 GIT binary patch literal 65 zcmZ?q402{*U|<4bhL9jvS0E+HV4z^Y<=qr}%;|LA&IJiiy? 1665802395 +0900 commit (initial): blah +8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf 8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf CI 1665802396 +0900 reset: moving to HEAD diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..698928dd3 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf CI 1665802395 +0900 commit (initial): blah diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash new file mode 100644 index 000000000..02b7af510 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 c6f35659c0cf57c794d79df88283d7ee933831dd CI 1665802399 +0900 On master: bar baz diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 new file mode 100644 index 0000000000000000000000000000000000000000..2a62b4b9d117b02f668e94e9d15e38d53e04515e GIT binary patch literal 31 ncmbe\wxKYn'T&%k͹QEʹ$9`] a4_C^ \ No newline at end of file diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf new file mode 100644 index 000000000..98e81aa49 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf @@ -0,0 +1,2 @@ +x +0 a}ɺ4$ "h +Qw烿Z_/p2i)LiFFOd,Qd5wR?}kL3ܧ\߻J`51t~?+ \ No newline at end of file diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/c6/f35659c0cf57c794d79df88283d7ee933831dd b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/c6/f35659c0cf57c794d79df88283d7ee933831dd new file mode 100644 index 0000000000000000000000000000000000000000..0eda983672af0f73b4c2736daef7cb465e6ca4f0 GIT binary patch literal 181 zcmV;m080OO0gcbQY6CG4h2hlu6zT&;*OA5q6L96q&oG(`2}EAAks*(ttz5e}&Ck~y zUdQ;JF6Q<&H&tg0(9Jxdi79~Zpc%bz43&^0m~k<)