-
Notifications
You must be signed in to change notification settings - Fork 116
/
iface.go
63 lines (54 loc) · 3 KB
/
iface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package github
import (
"context"
githubv3 "github.com/google/go-github/v54/github"
"github.com/shurcooL/githubv4"
)
// Wrapper around the go-github client because it has a different suggested
// testing strategy (wrap the struct) than most libraries (mock the interface)
// See https://github.com/google/go-github/issues/113#issuecomment-46023864
type v3client struct {
Repositories v3repositories
PullRequests v3pullrequests
Issues v3issues
Users v3users
Organizations v3organizations
}
// Interface for struct defined in https://github.com/google/go-github/blob/master/github/repos.go.
// Method comments below reproduced directly from original definition linked above.
type v3repositories interface {
// Create a new repository. If an org is specified, the new repository will be created under that org. If the empty string is specified, it will be created for the authenticated user.
Create(ctx context.Context, org string, repo *githubv3.Repository) (*githubv3.Repository, *githubv3.Response, error)
GetContents(ctx context.Context, owner, repo, path string, opt *githubv3.RepositoryContentGetOptions) (*githubv3.RepositoryContent, []*githubv3.RepositoryContent, *githubv3.Response, error)
CompareCommits(ctx context.Context, owner, repo string, base, head string, opts *githubv3.ListOptions) (*githubv3.CommitsComparison, *githubv3.Response, error)
GetCommit(ctx context.Context, owner, repo, sha string, opts *githubv3.ListOptions) (*githubv3.RepositoryCommit, *githubv3.Response, error)
}
// Interface for struct defined in https://github.com/google/go-github/blob/master/github/pulls.go.
// Method comments below reproduced directly from original definition linked above.
type v3pullrequests interface {
// Create a new pull request on the specified repository.
Create(ctx context.Context, owner string, repo string, pull *githubv3.NewPullRequest) (*githubv3.PullRequest, *githubv3.Response, error)
// ListPullRequestsWithCommit returns pull requests associated with a commit SHA.
ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *githubv3.ListOptions) ([]*githubv3.PullRequest, *githubv3.Response, error)
}
type v4client interface {
Query(ctx context.Context, q interface{}, variables map[string]interface{}) error
Mutate(ctx context.Context, m interface{}, input githubv4.Input, variables map[string]interface{}) error
}
type v3issues interface {
CreateComment(
ctx context.Context,
owner string,
repo string,
number int,
comment *githubv3.IssueComment,
) (*githubv3.IssueComment, *githubv3.Response, error)
}
type v3users interface {
Get(ctx context.Context, user string) (*githubv3.User, *githubv3.Response, error)
}
type v3organizations interface {
Get(ctx context.Context, org string) (*githubv3.Organization, *githubv3.Response, error)
List(ctx context.Context, user string, opts *githubv3.ListOptions) ([]*githubv3.Organization, *githubv3.Response, error)
GetOrgMembership(ctx context.Context, user, org string) (*githubv3.Membership, *githubv3.Response, error)
}