Unverified Commit 15082c09 authored by Shawna Monero's avatar Shawna Monero Committed by GitHub
Browse files

backend: github service: add User object to response (#1626)

parent 539c68a1
Showing with 22 additions and 14 deletions
+22 -14
......@@ -364,7 +364,7 @@ func (s *svc) CompareCommits(ctx context.Context, ref *RemoteRef, compareSHA str
type Commit struct {
Files []*githubv3.CommitFile
Message string
Author *githubv3.CommitAuthor
Author *githubv3.User
}
func (s *svc) GetCommit(ctx context.Context, ref *RemoteRef) (*Commit, error) {
......@@ -372,10 +372,12 @@ func (s *svc) GetCommit(ctx context.Context, ref *RemoteRef) (*Commit, error) {
if err != nil {
return nil, err
}
// Currently we are using the Author (Github) rather than commit Author (Git)
return &Commit{
Files: commit.Files,
Message: commit.GetCommit().GetMessage(),
Author: commit.GetCommit().GetAuthor(),
Author: commit.GetAuthor(),
}, nil
}
......
......@@ -364,12 +364,14 @@ func TestCompareCommits(t *testing.T) {
}
var getCommitsTests = []struct {
name string
errorText string
mockRepo *mockRepositories
file string
message string
authorLogin string
name string
errorText string
mockRepo *mockRepositories
file string
message string
authorLogin string
authorAvatarURL string
authorID int64
}{
{
name: "v3 error",
......@@ -377,11 +379,12 @@ var getCommitsTests = []struct {
errorText: "we've had a problem",
},
{
name: "happy path",
mockRepo: &mockRepositories{},
file: "testfile.go",
message: "committing some changes (#1)",
authorLogin: "foobar",
name: "happy path",
mockRepo: &mockRepositories{},
file: "testfile.go",
message: "committing some changes (#1)",
authorAvatarURL: "https://foo.bar/baz.png",
authorID: 1234,
},
}
......@@ -415,7 +418,10 @@ func TestGetCommit(t *testing.T) {
}
a.Equal(tt.file, *commit.Files[0].Filename)
a.Equal(tt.message, commit.Message)
a.Equal(tt.authorLogin, *commit.Author.Login)
if commit.Author != nil {
a.Equal(tt.authorAvatarURL, *commit.Author.AvatarURL)
a.Equal(tt.authorID, *commit.Author.ID)
}
a.Nil(err)
})
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment