-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1225 from lyft/issue-1193
[1193] Fix merge strategy for gh apps
- Loading branch information
Showing
20 changed files
with
362 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,13 @@ import ( | |
"fmt" | ||
"testing" | ||
|
||
. "github.com/petergtz/pegomock" | ||
"github.com/runatlantis/atlantis/server/events" | ||
eventMocks "github.com/runatlantis/atlantis/server/events/mocks" | ||
"github.com/runatlantis/atlantis/server/events/models" | ||
"github.com/runatlantis/atlantis/server/events/vcs" | ||
"github.com/runatlantis/atlantis/server/events/vcs/fixtures" | ||
vcsMocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" | ||
. "github.com/runatlantis/atlantis/testing" | ||
) | ||
|
||
|
@@ -46,7 +49,8 @@ func TestClone_GithubAppNoneExisting(t *testing.T) { | |
GithubHostname: testServer, | ||
} | ||
|
||
cloneDir, _, err := gwd.Clone(nil, models.Repo{}, models.Repo{}, models.PullRequest{ | ||
cloneDir, _, err := gwd.Clone(nil, models.Repo{}, models.PullRequest{ | ||
BaseRepo: models.Repo{}, | ||
HeadBranch: "branch", | ||
}, "default") | ||
Ok(t, err) | ||
|
@@ -55,3 +59,40 @@ func TestClone_GithubAppNoneExisting(t *testing.T) { | |
actCommit := runCmd(t, cloneDir, "git", "rev-parse", "HEAD") | ||
Equals(t, expCommit, actCommit) | ||
} | ||
|
||
func TestClone_GithubAppSetsCorrectUrl(t *testing.T) { | ||
workingDir := eventMocks.NewMockWorkingDir() | ||
|
||
credentials := vcsMocks.NewMockGithubCredentials() | ||
|
||
ghAppWorkingDir := events.GithubAppWorkingDir{ | ||
WorkingDir: workingDir, | ||
Credentials: credentials, | ||
GithubHostname: "some-host", | ||
} | ||
|
||
baseRepo, _ := models.NewRepo( | ||
models.Github, | ||
"runatlantis/atlantis", | ||
"https://github.com/runatlantis/atlantis.git", | ||
|
||
// user and token have to be blank otherwise this proxy wouldn't be invoked to begin with | ||
"", | ||
"", | ||
) | ||
|
||
headRepo := baseRepo | ||
|
||
modifiedBaseRepo := baseRepo | ||
modifiedBaseRepo.CloneURL = "https://x-access-token:[email protected]/runatlantis/atlantis.git" | ||
modifiedBaseRepo.SanitizedCloneURL = "https://x-access-token:<redacted>@github.com/runatlantis/atlantis.git" | ||
|
||
When(credentials.GetToken()).ThenReturn("token", nil) | ||
When(workingDir.Clone(nil, modifiedBaseRepo, models.PullRequest{BaseRepo: modifiedBaseRepo}, "default")).ThenReturn( | ||
"", true, nil, | ||
) | ||
|
||
_, success, _ := ghAppWorkingDir.Clone(nil, headRepo, models.PullRequest{BaseRepo: baseRepo}, "default") | ||
|
||
Assert(t, success == true, "clone url mutation error") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.