1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-09 07:24:03 +02:00

add tag checkout test

This commit is contained in:
Jesse Duffield 2023-02-20 18:45:14 +11:00
parent 76109a4c44
commit daf8176dd7
3 changed files with 36 additions and 0 deletions
pkg/integration

@ -136,6 +136,10 @@ func (self *Shell) EmptyCommit(message string) *Shell {
return self.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message)) 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 // convenience method for creating a file and adding it
func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell { func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell {
return self. return self.

@ -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"),
)
},
})

@ -86,6 +86,7 @@ var tests = []*components.IntegrationTest{
sync.Pull, sync.Pull,
sync.PullAndSetUpstream, sync.PullAndSetUpstream,
sync.RenameBranchAndPull, sync.RenameBranchAndPull,
tag.Checkout,
tag.CrudAnnotated, tag.CrudAnnotated,
tag.CrudLightweight, tag.CrudLightweight,
undo.UndoCheckoutAndDrop, undo.UndoCheckoutAndDrop,