Skip to content

Commit

Permalink
style(core/github): rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdidierlaurent committed May 29, 2020
1 parent 1366141 commit 9143a4b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions monitorables/github/api/models/pullrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type PullRequest struct {
Title string
Author coreModels.Author

Owner string
Repository string
Branch string
CommitSHA string
SourceOwner string
SourceRepository string
SourceBranch string
CommitSHA string
}
12 changes: 6 additions & 6 deletions monitorables/github/api/repository/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ func (gr *githubRepository) GetPullRequests(owner, repository string) ([]models.

func fillPullRequest(pr *githubApi.PullRequest) *models.PullRequest {
pullRequest := &models.PullRequest{
ID: pr.GetNumber(),
Title: pr.GetTitle(),
Owner: pr.GetHead().GetUser().GetLogin(),
Repository: pr.GetHead().GetRepo().GetName(),
Branch: pr.GetHead().GetRef(),
CommitSHA: pr.GetHead().GetSHA(),
ID: pr.GetNumber(),
Title: pr.GetTitle(),
SourceOwner: pr.GetHead().GetUser().GetLogin(),
SourceRepository: pr.GetHead().GetRepo().GetName(),
SourceBranch: pr.GetHead().GetRef(),
CommitSHA: pr.GetHead().GetSHA(),
}

if pr.GetUser() != nil {
Expand Down
12 changes: 6 additions & 6 deletions monitorables/github/api/repository/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ func TestRepository_GetPullRequest_Success(t *testing.T) {
assert.Equal(t, 10, pullRequest.ID)
assert.Equal(t, "avatar-user-login", pullRequest.Author.Name)
assert.Equal(t, "http:https://avatar.example.com", pullRequest.Author.AvatarURL)
assert.Equal(t, "owner-user-login", pullRequest.Owner)
assert.Equal(t, "repo-name", pullRequest.Repository)
assert.Equal(t, "feat/new-feature", pullRequest.Branch)
assert.Equal(t, "owner-user-login", pullRequest.SourceOwner)
assert.Equal(t, "repo-name", pullRequest.SourceRepository)
assert.Equal(t, "feat/new-feature", pullRequest.SourceBranch)
assert.Equal(t, "xxxx", pullRequest.CommitSHA)

mocksPullRequestService.AssertNumberOfCalls(t, "Get", 1)
Expand Down Expand Up @@ -302,9 +302,9 @@ func TestRepository_GetPullRequests_Success(t *testing.T) {
assert.Equal(t, 10, pullRequests[0].ID)
assert.Equal(t, "avatar-user-login", pullRequests[0].Author.Name)
assert.Equal(t, "http:https://avatar.example.com", pullRequests[0].Author.AvatarURL)
assert.Equal(t, "owner-user-login", pullRequests[0].Owner)
assert.Equal(t, "repo-name", pullRequests[0].Repository)
assert.Equal(t, "feat/new-feature", pullRequests[0].Branch)
assert.Equal(t, "owner-user-login", pullRequests[0].SourceOwner)
assert.Equal(t, "repo-name", pullRequests[0].SourceRepository)
assert.Equal(t, "feat/new-feature", pullRequests[0].SourceBranch)
assert.Equal(t, "xxxx", pullRequests[0].CommitSHA)

mocksPullRequestService.AssertNumberOfCalls(t, "List", 1)
Expand Down
6 changes: 3 additions & 3 deletions monitorables/github/api/usecase/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ func (gu *githubUsecase) PullRequest(params *models.PullRequestParams) (*coreMod
}

tile.Label = params.Repository
tile.Build.Branch = pointer.ToString(git.HumanizeBranch(pullRequest.Branch))
if params.Owner != pullRequest.Owner {
tile.Build.Branch = pointer.ToString(fmt.Sprintf("%s:%s", pullRequest.Owner, *tile.Build.Branch))
tile.Build.Branch = pointer.ToString(git.HumanizeBranch(pullRequest.SourceBranch))
if params.Owner != pullRequest.SourceOwner {
tile.Build.Branch = pointer.ToString(fmt.Sprintf("%s:%s", pullRequest.SourceOwner, *tile.Build.Branch))
}
tile.Build.MergeRequest = &coreModels.TileMergeRequest{
ID: pullRequest.ID,
Expand Down
2 changes: 1 addition & 1 deletion monitorables/github/api/usecase/github_faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (gu *githubUsecase) PullRequest(params *models.PullRequestParams) (tile *co
tile = coreModels.NewTile(api.GithubPullRequestTileType).WithBuild()
tile.Label = params.Repository

projectID := fmt.Sprintf("%s-%s-%s", params.Owner, params.Repository, params.ID)
projectID := fmt.Sprintf("%s-%s-%d", params.Owner, params.Repository, params.ID)
tile.Status = nonempty.Struct(params.Status, gu.computeStatus(projectID)).(coreModels.TileStatus)

if tile.Status == coreModels.DisabledStatus {
Expand Down
30 changes: 15 additions & 15 deletions monitorables/github/api/usecase/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestChecks_Failure(t *testing.T) {
}, nil)
mockRepository.On("GetCommit", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("string")).
Return(&models.Commit{
Author: &coreModels.Author{
Author: coreModels.Author{
Name: "test",
AvatarURL: "https://test.example.com",
},
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestPullRequest_ErrorOnChecks(t *testing.T) {
func TestPullRequest_NoChecks(t *testing.T) {
mockRepository := new(mocks.Repository)
mockRepository.On("GetPullRequest", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("int")).
Return(&models.PullRequest{ID: 10, Title: "Test", Owner: "test2", Branch: "master", CommitSHA: "xxx"}, nil)
Return(&models.PullRequest{ID: 10, Title: "Test", SourceOwner: "test2", SourceBranch: "master", CommitSHA: "xxx"}, nil)
mockRepository.On("GetChecks", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("string")).
Return(&models.Checks{}, nil)

Expand Down Expand Up @@ -344,11 +344,11 @@ func TestPullRequest_Success(t *testing.T) {
mockRepository := new(mocks.Repository)
mockRepository.On("GetPullRequest", AnythingOfType("string"), AnythingOfType("string"), AnythingOfType("int")).
Return(&models.PullRequest{
ID: 10,
Title: "Test",
Owner: "test2",
Branch: "master",
CommitSHA: "xxx",
ID: 10,
Title: "Test",
SourceOwner: "test2",
SourceBranch: "master",
CommitSHA: "xxx",
Author: coreModels.Author{
Name: "test",
AvatarURL: "https://test.example.com",
Expand Down Expand Up @@ -415,16 +415,16 @@ func TestPullRequestsGenerator_Success(t *testing.T) {
mockRepository.On("GetPullRequests", AnythingOfType("string"), AnythingOfType("string")).
Return([]models.PullRequest{
{
ID: 2,
Owner: "test",
Repository: "test",
CommitSHA: "xxxx",
ID: 2,
SourceOwner: "test",
SourceRepository: "test",
CommitSHA: "xxxx",
},
{
ID: 3,
Owner: "test",
Repository: "test",
CommitSHA: "yyyy",
ID: 3,
SourceOwner: "test",
SourceRepository: "test",
CommitSHA: "yyyy",
},
}, nil)

Expand Down

0 comments on commit 9143a4b

Please sign in to comment.