Skip to content

Commit

Permalink
test: add test for existing branch with matching start
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavkj committed Nov 25, 2023
1 parent 391bece commit 6614064
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,40 @@ func TestTable(t *testing.T) {
},
},

{
name: "existing branch with matching start",
vcCreate: func(t *testing.T) *vcmock.VersionController {
repo := createRepo(t, "owner", "should-change", "i like apples")
changeBranch(t, repo.Path, "custom-branch-name-but-with-different-ending", true)
changeTestFile(t, repo.Path, "i like apple", "test change")
changeBranch(t, repo.Path, "master", false)
return &vcmock.VersionController{
Repositories: []vcmock.Repository{
repo,
},
}
},
args: []string{
"run",
"--author-name", "Test Author",
"--author-email", "[email protected]",
"--branch", "custom-branch-name",
"-m", "custom message",
changerBinaryPath,
},
verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) {
require.Len(t, vcMock.PullRequests, 1)
assert.Equal(t, "custom-branch-name", vcMock.PullRequests[0].Head)
assert.Equal(t, "custom message", vcMock.PullRequests[0].Title)

changeBranch(t, vcMock.Repositories[0].Path, "custom-branch-name", false)
assert.Equal(t, "i like bananas", readTestFile(t, vcMock.Repositories[0].Path))

changeBranch(t, vcMock.Repositories[0].Path, "custom-branch-name-but-with-different-ending", false)
assert.Equal(t, "i like apple", readTestFile(t, vcMock.Repositories[0].Path))
},
},

{
name: "reviewers",
vcCreate: func(t *testing.T) *vcmock.VersionController {
Expand Down

0 comments on commit 6614064

Please sign in to comment.