/
drygithubclient.go
58 lines (45 loc) · 1.91 KB
/
drygithubclient.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
package autoupdate
import (
"context"
"go.uber.org/zap"
"github.com/simplesurance/goordinator/internal/githubclt"
)
const headCommitID = "32d4ff96ea72412277bbfd22ff1bab3a5263b415"
// DryGithubClient is a github-client that does not do any changes on github.
// All operations that could cause a change are simulated and always succeed.
// All all other operations are forwarded to a wrapped GithubClient.
type DryGithubClient struct {
clt GithubClient
logger *zap.Logger
}
func NewDryGithubClient(clt GithubClient, logger *zap.Logger) *DryGithubClient {
return &DryGithubClient{
clt: clt,
logger: logger.Named("dry_github_client"),
}
}
func (c *DryGithubClient) UpdateBranch(context.Context, string, string, int) (*githubclt.UpdateBranchResult, error) {
c.logger.Info("simulated updating of github branch, returning is uptodate")
return &githubclt.UpdateBranchResult{HeadCommitID: headCommitID}, nil
}
func (c *DryGithubClient) ReadyForMerge(context.Context, string, string, int) (*githubclt.ReadyForMergeStatus, error) {
c.logger.Info("simulated fetching ready for merge status, pr is approved, all checks successful")
return &githubclt.ReadyForMergeStatus{
ReviewDecision: githubclt.ReviewDecisionApproved,
CIStatus: githubclt.CIStatusSuccess,
Commit: headCommitID,
}, nil
}
func (c *DryGithubClient) CreateIssueComment(context.Context, string, string, int, string) error {
c.logger.Info("simulated creating of github issue comment, no comment created on github")
return nil
}
func (c *DryGithubClient) ListPullRequests(ctx context.Context, owner, repo, state, sort, sortDirection string) githubclt.PRIterator {
return c.clt.ListPullRequests(ctx, owner, repo, state, sort, sortDirection)
}
func (*DryGithubClient) AddLabel(context.Context, string, string, int, string) error {
return nil
}
func (*DryGithubClient) RemoveLabel(context.Context, string, string, int, string) error {
return nil
}