mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-12 16:46:25 -04:00
Add tests demonstrating the problem
Trying to delete a remote tag when a remote branch with the same name exists results in an error, and vice versa.
This commit is contained in:
parent
19a4454599
commit
4d4b143cc7
|
|
@ -0,0 +1,54 @@
|
|||
package branch
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var DeleteRemoteBranchWhenTagWithSameNameExists = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Delete a remote branch when a remote tag with the same name exists",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.CreateLightweightTag("xyz", "HEAD")
|
||||
shell.PushBranch("origin", "HEAD:refs/tags/xyz") // abusing PushBranch to push a tag
|
||||
shell.PushBranch("origin", "HEAD:refs/heads/xyz")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Remotes().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("origin").IsSelected(),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().RemoteBranches().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
Contains("xyz"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
t.ExpectPopup().
|
||||
Confirmation().
|
||||
Title(Equals("Delete branch 'xyz'?")).
|
||||
Content(Equals("Are you sure you want to delete the remote branch 'xyz' from 'origin'?")).
|
||||
Confirm()
|
||||
|
||||
/* EXPECTED:
|
||||
t.Views().RemoteBranches().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
)
|
||||
ACTUAL: */
|
||||
t.ExpectPopup().Alert().
|
||||
Title(Equals("Error")).
|
||||
Content(Contains("error: dst refspec xyz matches more than one")).
|
||||
Confirm()
|
||||
},
|
||||
})
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package tag
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var DeleteRemoteTagWhenBranchWithSameNameExists = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Delete a remote tag when a remote branch with the same name exists",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.CreateLightweightTag("xyz", "HEAD")
|
||||
shell.PushBranch("origin", "HEAD:refs/tags/xyz") // abusing PushBranch to push a tag
|
||||
shell.PushBranch("origin", "HEAD:refs/heads/xyz")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Tags().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("xyz").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
t.ExpectPopup().
|
||||
Menu().
|
||||
Title(Equals("Delete tag 'xyz'?")).
|
||||
Select(Contains("Delete remote tag")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Equals("Remote from which to remove tag 'xyz':")).
|
||||
InitialText(Equals("origin")).
|
||||
SuggestionLines(
|
||||
Contains("origin"),
|
||||
).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().
|
||||
Confirmation().
|
||||
Title(Equals("Delete tag 'xyz'?")).
|
||||
Content(Equals("Are you sure you want to delete the remote tag 'xyz' from 'origin'?")).
|
||||
Confirm()
|
||||
|
||||
/* EXPECTED:
|
||||
t.ExpectToast(Equals("Remote tag deleted"))
|
||||
|
||||
t.Shell().AssertRemoteTagNotFound("origin", "xyz")
|
||||
ACTUAL: */
|
||||
t.ExpectPopup().Alert().
|
||||
Title(Equals("Error")).
|
||||
Content(Contains("error: dst refspec xyz matches more than one")).
|
||||
Confirm()
|
||||
},
|
||||
})
|
||||
|
|
@ -45,6 +45,7 @@ var tests = []*components.IntegrationTest{
|
|||
branch.CreateTag,
|
||||
branch.Delete,
|
||||
branch.DeleteMultiple,
|
||||
branch.DeleteRemoteBranchWhenTagWithSameNameExists,
|
||||
branch.DeleteRemoteBranchWithCredentialPrompt,
|
||||
branch.DeleteRemoteBranchWithDifferentName,
|
||||
branch.DeleteWhileFiltering,
|
||||
|
|
@ -430,6 +431,7 @@ var tests = []*components.IntegrationTest{
|
|||
tag.CrudAnnotated,
|
||||
tag.CrudLightweight,
|
||||
tag.DeleteLocalAndRemote,
|
||||
tag.DeleteRemoteTagWhenBranchWithSameNameExists,
|
||||
tag.ForceTagAnnotated,
|
||||
tag.ForceTagLightweight,
|
||||
tag.Reset,
|
||||
|
|
|
|||
Loading…
Reference in a new issue