From 5e9a897348945a5382025f3b2e574bf3b2e22389 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 28 Dec 2022 13:35:00 +1100 Subject: [PATCH] migrate ignore gitignore integration test --- .../tests/file/exclude_gitignore.go | 39 ++++++++++++++++++ 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/config | 10 ----- .../expected/repo/.git_keep/description | 1 - .../expected/repo/.git_keep/index | Bin 65 -> 0 bytes .../expected/repo/.git_keep/info/exclude | 7 ---- .../expected/repo/.git_keep/logs/HEAD | 1 - .../repo/.git_keep/logs/refs/heads/master | 1 - .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 15 -> 0 bytes .../e9/76bc07c8784964cf239ac9fbdc3535df55269c | Bin 123 -> 0 bytes .../expected/repo/.git_keep/refs/heads/master | 1 - .../expected/repo/lg_ignore_file | 1 - .../excludeGitIgnore/recording.json | 1 - test/integration/excludeGitIgnore/setup.sh | 15 ------- test/integration/excludeGitIgnore/test.json | 4 -- 18 files changed, 40 insertions(+), 44 deletions(-) create mode 100644 pkg/integration/tests/file/exclude_gitignore.go delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/FETCH_HEAD delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/config delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/description delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/index delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/info/exclude delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/HEAD delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/e9/76bc07c8784964cf239ac9fbdc3535df55269c delete mode 100644 test/integration/excludeGitIgnore/expected/repo/.git_keep/refs/heads/master delete mode 100644 test/integration/excludeGitIgnore/expected/repo/lg_ignore_file delete mode 100644 test/integration/excludeGitIgnore/recording.json delete mode 100644 test/integration/excludeGitIgnore/setup.sh delete mode 100644 test/integration/excludeGitIgnore/test.json diff --git a/pkg/integration/tests/file/exclude_gitignore.go b/pkg/integration/tests/file/exclude_gitignore.go new file mode 100644 index 000000000..7db56d994 --- /dev/null +++ b/pkg/integration/tests/file/exclude_gitignore.go @@ -0,0 +1,39 @@ +package file + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ExcludeGitignore = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Failed attempt at excluding and ignoring the .gitignore file", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) { + }, + SetupRepo: func(shell *Shell) { + shell.CreateFile(".gitignore", "") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Lines( + Contains(`?? .gitignore`).IsSelected(), + ). + Press(keys.Files.IgnoreFile). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm() + }). + Press(keys.Files.IgnoreFile). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm() + }) + + t.FileSystem().FileContainsContent(".gitignore", Equals("")) + t.FileSystem().FileContainsContent(".git/info/exclude", DoesNotContain(".gitignore")) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 9278ade2b..da72f84ed 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -54,6 +54,7 @@ var tests = []*components.IntegrationTest{ file.DirWithUntrackedFile, file.DiscardChanges, file.DiscardStagedChanges, + file.ExcludeGitignore, interactive_rebase.AmendMerge, interactive_rebase.One, stash.Rename, diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 5852f4463..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -Initial commit diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/FETCH_HEAD b/test/integration/excludeGitIgnore/expected/repo/.git_keep/FETCH_HEAD deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD b/test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/config b/test/integration/excludeGitIgnore/expected/repo/.git_keep/config deleted file mode 100644 index 8ae104545..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/config +++ /dev/null @@ -1,10 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true - precomposeunicode = true -[user] - email = CI@example.com - name = CI diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/description b/test/integration/excludeGitIgnore/expected/repo/.git_keep/description deleted file mode 100644 index 498b267a8..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/index b/test/integration/excludeGitIgnore/expected/repo/.git_keep/index deleted file mode 100644 index 65d675154f23ffb2d0196e017d44a5e7017550f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65 zcmZ?q402{*U|<4bhL9jvS0E+HV4z^Y<=qr}%;|LA&IJiiy? 1657012812 +1000 commit (initial): Initial commit diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index bad114b22..000000000 --- a/test/integration/excludeGitIgnore/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 e976bc07c8784964cf239ac9fbdc3535df55269c CI 1657012812 +1000 commit (initial): Initial commit diff --git a/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration/excludeGitIgnore/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 deleted file mode 100644 index adf64119a33d7621aeeaa505d30adb58afaa5559..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15 Wcmb0EGW|0ga783c@fD06pgwdlzIkCUFBILQi={l5R237%40Gd<%ZS>oCLA(R))M ze?I6Y0 .gitignore - diff --git a/test/integration/excludeGitIgnore/test.json b/test/integration/excludeGitIgnore/test.json deleted file mode 100644 index 9c466ba11..000000000 --- a/test/integration/excludeGitIgnore/test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "description": "In this test we attempt to add .gitignore to .git/info/exclude to ensure lazygit rejects the action", - "speed": 5 -}