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:
Stefan Haller 2025-11-27 19:44:26 +01:00
parent 19a4454599
commit 4d4b143cc7
3 changed files with 114 additions and 0 deletions

View file

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

View file

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

View file

@ -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,