forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 86
/
pr.go
65 lines (53 loc) · 1.95 KB
/
pr.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
64
65
package fake
import (
"context"
"fmt"
"github.com/jenkins-x/go-scm/scm"
)
type pullService struct {
client *wrapper
data *Data
}
func (s *pullService) Find(ctx context.Context, repo string, number int) (*scm.PullRequest, *scm.Response, error) {
f := s.data
val, exists := f.PullRequests[number]
if !exists {
return nil, nil, fmt.Errorf("Pull request number %d does not exit", number)
}
return val, nil, nil
}
func (s *pullService) FindComment(context.Context, string, int, int) (*scm.Comment, *scm.Response, error) {
panic("implement me")
}
func (s *pullService) List(context.Context, string, scm.PullRequestListOptions) ([]*scm.PullRequest, *scm.Response, error) {
panic("implement me")
}
func (s *pullService) ListChanges(ctx context.Context, repo string, number int, opts scm.ListOptions) ([]*scm.Change, *scm.Response, error) {
f := s.data
return f.PullRequestChanges[number], nil, nil
}
func (s *pullService) ListComments(ctx context.Context, repo string, number int, opts scm.ListOptions) ([]*scm.Comment, *scm.Response, error) {
f := s.data
return append([]*scm.Comment{}, f.PullRequestComments[number]...), nil, nil
}
func (s *pullService) Merge(context.Context, string, int) (*scm.Response, error) {
panic("implement me")
}
func (s *pullService) Close(context.Context, string, int) (*scm.Response, error) {
panic("implement me")
}
func (s *pullService) CreateComment(ctx context.Context, repo string, number int, comment *scm.CommentInput) (*scm.Comment, *scm.Response, error) {
f := s.data
f.IssueCommentsAdded = append(f.IssueCommentsAdded, fmt.Sprintf("%s#%d:%s", repo, number, comment.Body))
answer := &scm.Comment{
ID: f.IssueCommentID,
Body: comment.Body,
Author: scm.User{Login: botName},
}
f.IssueComments[number] = append(f.IssueComments[number], answer)
f.IssueCommentID++
return answer, nil, nil
}
func (s *pullService) DeleteComment(context.Context, string, int, int) (*scm.Response, error) {
panic("implement me")
}