From a30d924afe8e996dd0517bc70855803858efc362 Mon Sep 17 00:00:00 2001 From: Andrew Hynes Date: Thu, 6 Oct 2022 22:53:13 -0230 Subject: [PATCH] test: add test for stash including untracked files --- pkg/integration/tests/stash/stash.go | 2 ++ .../stash/stash_including_untracked_files.go | 33 ++++++++++++++++++ pkg/integration/tests/tests.go | 1 + .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../expected/repo/.git_keep/HEAD | 1 + .../expected/repo/.git_keep/ORIG_HEAD | 1 + .../expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 65 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 2 ++ .../repo/.git_keep/logs/refs/heads/master | 1 + .../expected/repo/.git_keep/logs/refs/stash | 1 + .../18/77c1658e50742642146b3bbb24c6b8635c7b64 | Bin 0 -> 51 bytes .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 0 -> 15 bytes .../6b/584e8ece562ebffc15d38808cd6b98fc3d97ea | Bin 0 -> 22 bytes .../9d/49589525f6c37d177a53a57d82603a22de6076 | Bin 0 -> 170 bytes .../b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 | 2 ++ .../d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f | Bin 0 -> 122 bytes .../dd/e611c48bd5d6df4157b99f524929851b07eca9 | Bin 0 -> 51 bytes .../f8/528a899ebb020e575e007426baa4535207a214 | 2 ++ .../expected/repo/.git_keep/refs/heads/master | 1 + .../expected/repo/.git_keep/refs/stash | 1 + 24 files changed, 68 insertions(+) create mode 100644 pkg/integration/tests/stash/stash_including_untracked_files.go create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/description create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/index create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/6b/584e8ece562ebffc15d38808cd6b98fc3d97ea create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/9d/49589525f6c37d177a53a57d82603a22de6076 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/f8/528a899ebb020e575e007426baa4535207a214 create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/refs/stash diff --git a/pkg/integration/tests/stash/stash.go b/pkg/integration/tests/stash/stash.go index db9e13b78..af247550b 100644 --- a/pkg/integration/tests/stash/stash.go +++ b/pkg/integration/tests/stash/stash.go @@ -17,6 +17,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.StashCount(0) + assert.WorkingTreeFileCount(1) input.PressKeys(keys.Files.ViewStashOptions) assert.InMenu() @@ -26,5 +27,6 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ input.Confirm() assert.StashCount(1) + assert.WorkingTreeFileCount(0) }, }) diff --git a/pkg/integration/tests/stash/stash_including_untracked_files.go b/pkg/integration/tests/stash/stash_including_untracked_files.go new file mode 100644 index 000000000..4ed7957ac --- /dev/null +++ b/pkg/integration/tests/stash/stash_including_untracked_files.go @@ -0,0 +1,33 @@ +package stash + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Stashing all files including untracked ones", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("initial commit") + shell.CreateFile("file_1", "content") + shell.CreateFile("file_2", "content") + shell.GitAdd("file_1") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.StashCount(0) + assert.WorkingTreeFileCount(2) + + input.PressKeys(keys.Files.ViewStashOptions) + assert.InMenu() + + input.PressKeys("U") + input.Type("stash name") + input.Confirm() + + assert.StashCount(1) + assert.WorkingTreeFileCount(0) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index fd42f0ed6..028e990ee 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -29,6 +29,7 @@ var tests = []*components.IntegrationTest{ custom_commands.MultiplePrompts, custom_commands.MenuFromCommand, stash.Stash, + stash.StashIncludingUntrackedFiles, } func GetTests() []*components.IntegrationTest { diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..802607664 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +initial commit diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD new file mode 100644 index 000000000..4ee40e25d --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/ORIG_HEAD @@ -0,0 +1 @@ +d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/config new file mode 100644 index 000000000..8a748ce32 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/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/stash_including_untracked_files/expected/repo/.git_keep/description b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/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/stash_including_untracked_files/expected/repo/.git_keep/index b/test/integration_new/stash/stash_including_untracked_files/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? 1665105632 -0230 commit (initial): initial commit +d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f CI 1665105633 -0230 reset: moving to HEAD diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..df042a3dd --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 d25b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f CI 1665105632 -0230 commit (initial): initial commit diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash new file mode 100644 index 000000000..335d6aab8 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/logs/refs/stash @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 b8eb39e727d4ac91542d57faa0bea0458c2d30e3 CI 1665105633 -0230 On master: stash name diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/18/77c1658e50742642146b3bbb24c6b8635c7b64 new file mode 100644 index 0000000000000000000000000000000000000000..c5ff32d892058a343ef1582aee42127eb222f8ca GIT binary patch literal 51 zcmV-30L=e*0V^p=O;s>9VK6i>Ff%bxNXyJgjW=S*j_~U{7pAxWkLcwNj%%m`r=`i7gC0>s|2a2p5q-kC YKTncL_5c6? literal 0 HcmV?d00001 diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 new file mode 100644 index 000000000..eb6b19046 --- /dev/null +++ b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/b8/eb39e727d4ac91542d57faa0bea0458c2d30e3 @@ -0,0 +1,2 @@ +xMJ1`}\@#"¬f* +#;Ƿ7wx׶1nT-"F9R:S(T2cdMr锸R╠aŜC[N"TK1M዆¹0q'ŔpL Ň)K>Kj*3A°ϼm\a2Ҷ0FF{yz?!_1帹UY` \ No newline at end of file diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/d2/5b2c8a3d20c1b1884fbf1c87aa2014dd99ed7f new file mode 100644 index 0000000000000000000000000000000000000000..d412fdb6927f1dfd30d03f4a72a0f11807a62c58 GIT binary patch literal 122 zcmV-=0EPc}0ga7Y3c@fD0R7G>_5#Z0u}cCXLce;9Y`VojW28jz_!hi?zrzeudTVun zC4U;bDg=p+mcqdmVU?7TQ7On87fvq5Ra8U5VDfuB`VP|!*J-}%C%4z8m(tq}EHhao c_72YIJeq?Zlc9g=ratSad4pePzI(tguaL(&(f|Me literal 0 HcmV?d00001 diff --git a/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 b/test/integration_new/stash/stash_including_untracked_files/expected/repo/.git_keep/objects/dd/e611c48bd5d6df4157b99f524929851b07eca9 new file mode 100644 index 0000000000000000000000000000000000000000..1721a0ff4e35747e550d2943331beb3c1e434a45 GIT binary patch literal 51 zcmV-30L=e*0V^p=O;s>9VK6i>Ff%bxNXyJgjW=Y-j_~U{7pAxWkLcwNj