summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-20 18:45:14 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-20 19:01:08 +1100
commitdaf8176dd74eedcbb4d4916f1e918bcae1361b95 (patch)
treebd547185e081a468b5e769edcb4ce4573468ba55 /pkg
parent76109a4c441f3b0fc8265823bbc3d58f41aaec50 (diff)
add tag checkout test
Diffstat (limited to 'pkg')
-rw-r--r--pkg/integration/components/shell.go4
-rw-r--r--pkg/integration/tests/tag/checkout.go31
-rw-r--r--pkg/integration/tests/tests_gen.go1
3 files changed, 36 insertions, 0 deletions
diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go
index ad4964507..ad6d195f5 100644
--- a/pkg/integration/components/shell.go
+++ b/pkg/integration/components/shell.go
@@ -136,6 +136,10 @@ func (self *Shell) EmptyCommit(message string) *Shell {
return self.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message))
}
+func (self *Shell) CreateLightweightTag(name string, ref string) *Shell {
+ return self.RunCommand(fmt.Sprintf("git tag %s %s", name, ref))
+}
+
// convenience method for creating a file and adding it
func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell {
return self.
diff --git a/pkg/integration/tests/tag/checkout.go b/pkg/integration/tests/tag/checkout.go
new file mode 100644
index 000000000..9ed88f980
--- /dev/null
+++ b/pkg/integration/tests/tag/checkout.go
@@ -0,0 +1,31 @@
+package tag
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Checkout a tag",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.CreateLightweightTag("tag", "HEAD^")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Tags().
+ Focus().
+ Lines(
+ Contains("tag").IsSelected(),
+ ).
+ PressPrimaryAction() // checkout tag
+
+ t.Views().Branches().IsFocused().Lines(
+ Contains("HEAD detached at tag").IsSelected(),
+ Contains("master"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go
index 4a6cbcf30..1e32bd784 100644
--- a/pkg/integration/tests/tests_gen.go
+++ b/pkg/integration/tests/tests_gen.go
@@ -86,6 +86,7 @@ var tests = []*components.IntegrationTest{
sync.Pull,
sync.PullAndSetUpstream,
sync.RenameBranchAndPull,
+ tag.Checkout,
tag.CrudAnnotated,
tag.CrudLightweight,
undo.UndoCheckoutAndDrop,