mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +02:00
test: add an integration test for creating tag on branches
This commit is contained in:
parent
67b08ac239
commit
36c2b00336
@ -14,6 +14,10 @@ func (self *Git) CurrentBranchName(expectedName string) *Git {
|
|||||||
return self.assert("git rev-parse --abbrev-ref HEAD", expectedName)
|
return self.assert("git rev-parse --abbrev-ref HEAD", expectedName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Git) TagNamesAt(ref string, expectedNames []string) *Git {
|
||||||
|
return self.assert(fmt.Sprintf(`git tag --contains "%s"`, ref), strings.Join(expectedNames, "\n"))
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Git) assert(cmdStr string, expected string) *Git {
|
func (self *Git) assert(cmdStr string, expected string) *Git {
|
||||||
self.assertWithRetries(func() (bool, string) {
|
self.assertWithRetries(func() (bool, string) {
|
||||||
output, err := self.shell.runCommandWithOutput(cmdStr)
|
output, err := self.shell.runCommandWithOutput(cmdStr)
|
||||||
|
47
pkg/integration/tests/branch/create_tag.go
Normal file
47
pkg/integration/tests/branch/create_tag.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package branch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Create a new tag on branch",
|
||||||
|
ExtraCmdArgs: "",
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.
|
||||||
|
CreateNCommits(10).
|
||||||
|
NewBranch("new-branch").
|
||||||
|
EmptyCommit("new commit")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
MatchesRegexp(`\*\s*new-branch`).IsSelected(),
|
||||||
|
MatchesRegexp(`master`),
|
||||||
|
).
|
||||||
|
SelectNextItem().
|
||||||
|
Press(keys.Branches.CreateTag)
|
||||||
|
|
||||||
|
t.ExpectPopup().Menu().
|
||||||
|
Title(Equals("Create tag")).
|
||||||
|
Confirm()
|
||||||
|
|
||||||
|
t.ExpectPopup().Prompt().
|
||||||
|
Title(Equals("Tag name:")).
|
||||||
|
Type("new-tag").
|
||||||
|
Confirm()
|
||||||
|
|
||||||
|
t.Views().Tags().
|
||||||
|
Lines(
|
||||||
|
MatchesRegexp(`new-tag`).IsSelected(),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.Git().
|
||||||
|
TagNamesAt("HEAD", []string{}).
|
||||||
|
TagNamesAt("master", []string{"new-tag"})
|
||||||
|
},
|
||||||
|
})
|
@ -27,6 +27,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
bisect.Basic,
|
bisect.Basic,
|
||||||
bisect.FromOtherBranch,
|
bisect.FromOtherBranch,
|
||||||
branch.CheckoutByName,
|
branch.CheckoutByName,
|
||||||
|
branch.CreateTag,
|
||||||
branch.Delete,
|
branch.Delete,
|
||||||
branch.DetachedHead,
|
branch.DetachedHead,
|
||||||
branch.OpenWithCliArg,
|
branch.OpenWithCliArg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user