|
8 | 8 | "net/url"
|
9 | 9 | "strings"
|
10 | 10 | "testing"
|
| 11 | + "time" |
11 | 12 |
|
12 | 13 | "github.com/go-semantic-release/semantic-release/v2/pkg/provider"
|
13 | 14 | "github.com/go-semantic-release/semantic-release/v2/pkg/semrel"
|
@@ -41,16 +42,31 @@ func TestNewGithubRepository(t *testing.T) {
|
41 | 42 | require.Equal("github.enterprise", repo.client.BaseURL.Host)
|
42 | 43 | }
|
43 | 44 |
|
44 |
| -func createGithubCommit(sha, message string) *github.RepositoryCommit { |
45 |
| - return &github.RepositoryCommit{SHA: &sha, Commit: &github.Commit{Message: &message}} |
46 |
| -} |
47 |
| - |
48 | 45 | var (
|
49 | 46 | commitType = "commit"
|
50 | 47 | tagType = "tag"
|
| 48 | + testSHA = "deadbeef" |
| 49 | + |
| 50 | + githubAuthorLogin = "author-login" |
| 51 | + githubAuthorName = "author" |
| 52 | + githubAuthorEmail = "[email protected]" |
| 53 | + githubTimestamp = time.Now() |
| 54 | + |
| 55 | + githubAuthor = &github.CommitAuthor{ |
| 56 | + Name: &githubAuthorName, |
| 57 | + Email: &githubAuthorEmail, |
| 58 | + Date: &githubTimestamp, |
| 59 | + } |
51 | 60 | )
|
52 | 61 |
|
53 |
| -var testSHA = "deadbeef" |
| 62 | +func createGithubCommit(sha, message string) *github.RepositoryCommit { |
| 63 | + return &github.RepositoryCommit{ |
| 64 | + SHA: &sha, |
| 65 | + Commit: &github.Commit{Message: &message, Author: githubAuthor, Committer: githubAuthor}, |
| 66 | + Author: &github.User{Login: &githubAuthorLogin}, |
| 67 | + Committer: &github.User{Login: &githubAuthorLogin}, |
| 68 | + } |
| 69 | +} |
54 | 70 |
|
55 | 71 | func createGithubRef(ref string) *github.Reference {
|
56 | 72 | return &github.Reference{Ref: &ref, Object: &github.GitObject{SHA: &testSHA, Type: &commitType}}
|
@@ -206,6 +222,14 @@ func TestGithubGetCommits(t *testing.T) {
|
206 | 222 | idxOff := i + 1
|
207 | 223 | require.Equal(t, c.SHA, githubCommits[idxOff].GetSHA())
|
208 | 224 | require.Equal(t, c.RawMessage, githubCommits[idxOff].Commit.GetMessage())
|
| 225 | + require.Equal(t, c.Annotations["author_login"], githubCommits[idxOff].GetAuthor().GetLogin()) |
| 226 | + require.Equal(t, c.Annotations["author_name"], githubCommits[idxOff].Commit.GetAuthor().GetName()) |
| 227 | + require.Equal(t, c.Annotations["author_email"], githubCommits[idxOff].Commit.GetAuthor().GetEmail()) |
| 228 | + require.Equal(t, c.Annotations["committer_login"], githubCommits[idxOff].GetCommitter().GetLogin()) |
| 229 | + require.Equal(t, c.Annotations["committer_name"], githubCommits[idxOff].Commit.GetCommitter().GetName()) |
| 230 | + require.Equal(t, c.Annotations["committer_email"], githubCommits[idxOff].Commit.GetCommitter().GetEmail()) |
| 231 | + require.Equal(t, c.Annotations["author_date"], githubCommits[idxOff].Commit.GetAuthor().GetDate().Format(time.RFC3339)) |
| 232 | + require.Equal(t, c.Annotations["committer_date"], githubCommits[idxOff].Commit.GetCommitter().GetDate().Format(time.RFC3339)) |
209 | 233 | }
|
210 | 234 | }
|
211 | 235 |
|
|
0 commit comments