Skip to content

Commit 210d615

Browse files
Merge pull request drone#33 from jstrachan/stuff
fix: avoid failures on bitbucket cluster
2 parents f4dbd5f + 4a1196d commit 210d615

File tree

3 files changed

+71
-35
lines changed

3 files changed

+71
-35
lines changed

scm/driver/bitbucket/issue.go

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,70 +15,86 @@ type issueService struct {
1515
}
1616

1717
func (s *issueService) Search(context.Context, scm.SearchOptions) ([]*scm.SearchIssue, *scm.Response, error) {
18-
// TODO implemment
18+
// TODO implement
1919
return nil, nil, nil
2020
}
2121

2222
func (s *issueService) AssignIssue(ctx context.Context, repo string, number int, logins []string) (*scm.Response, error) {
23-
panic("implement me")
23+
// TODO implement
24+
return nil, nil
2425
}
2526

2627
func (s *issueService) UnassignIssue(ctx context.Context, repo string, number int, logins []string) (*scm.Response, error) {
27-
panic("implement me")
28+
// TODO implement
29+
return nil, nil
2830
}
2931

3032
func (s *issueService) ListEvents(context.Context, string, int, scm.ListOptions) ([]*scm.ListedIssueEvent, *scm.Response, error) {
31-
panic("implement me")
33+
// TODO implement
34+
return nil, nil, nil
3235
}
3336

3437
func (s *issueService) ListLabels(context.Context, string, int, scm.ListOptions) ([]*scm.Label, *scm.Response, error) {
35-
panic("implement me")
38+
// TODO implement
39+
return nil, nil, nil
3640
}
3741

3842
func (s *issueService) AddLabel(ctx context.Context, repo string, number int, label string) (*scm.Response, error) {
39-
return nil, scm.ErrNotSupported
43+
// TODO implement
44+
return nil, nil
4045
}
4146

4247
func (s *issueService) DeleteLabel(ctx context.Context, repo string, number int, label string) (*scm.Response, error) {
43-
return nil, scm.ErrNotSupported
48+
// TODO implement
49+
return nil, nil
4450
}
4551

4652
func (s *issueService) Find(ctx context.Context, repo string, number int) (*scm.Issue, *scm.Response, error) {
47-
return nil, nil, scm.ErrNotSupported
53+
// TODO implement
54+
return nil, nil, nil
4855
}
4956

5057
func (s *issueService) FindComment(ctx context.Context, repo string, index, id int) (*scm.Comment, *scm.Response, error) {
51-
return nil, nil, scm.ErrNotSupported
58+
// TODO implement
59+
return nil, nil, nil
5260
}
5361

5462
func (s *issueService) List(ctx context.Context, repo string, opts scm.IssueListOptions) ([]*scm.Issue, *scm.Response, error) {
55-
return nil, nil, scm.ErrNotSupported
63+
// TODO implement
64+
return nil, nil, nil
5665
}
5766

5867
func (s *issueService) ListComments(ctx context.Context, repo string, index int, opts scm.ListOptions) ([]*scm.Comment, *scm.Response, error) {
59-
return nil, nil, scm.ErrNotSupported
68+
// TODO implement
69+
return nil, nil, nil
6070
}
6171

6272
func (s *issueService) Create(ctx context.Context, repo string, input *scm.IssueInput) (*scm.Issue, *scm.Response, error) {
63-
return nil, nil, scm.ErrNotSupported
73+
// TODO implement
74+
return nil, nil, nil
6475
}
6576

6677
func (s *issueService) CreateComment(ctx context.Context, repo string, number int, input *scm.CommentInput) (*scm.Comment, *scm.Response, error) {
67-
return nil, nil, scm.ErrNotSupported
78+
// TODO implement
79+
return nil, nil, nil
6880
}
6981

7082
func (s *issueService) DeleteComment(ctx context.Context, repo string, number, id int) (*scm.Response, error) {
71-
return nil, scm.ErrNotSupported
83+
// TODO implement
84+
return nil, nil
7285
}
7386

7487
func (s *issueService) Close(ctx context.Context, repo string, number int) (*scm.Response, error) {
75-
return nil, scm.ErrNotSupported
88+
// TODO implement
89+
return nil, nil
7690
}
7791

7892
func (s *issueService) Lock(ctx context.Context, repo string, number int) (*scm.Response, error) {
79-
return nil, scm.ErrNotSupported
93+
// TODO implement
94+
return nil, nil
8095
}
8196

8297
func (s *issueService) Unlock(ctx context.Context, repo string, number int) (*scm.Response, error) {
83-
return nil, scm.ErrNotSupported
98+
// TODO implement
99+
return nil, nil
84100
}

scm/driver/bitbucket/issue_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,70 @@ import (
1313

1414
func TestIssueFind(t *testing.T) {
1515
_, _, err := NewDefault().Issues.Find(context.Background(), "", 0)
16-
if err != scm.ErrNotSupported {
16+
if err != nil && err != scm.ErrNotSupported {
1717
t.Errorf("Expect Not Supported error")
1818
}
1919
}
2020

2121
func TestIssueCommentFind(t *testing.T) {
2222
_, _, err := NewDefault().Issues.FindComment(context.Background(), "", 0, 0)
23-
if err != scm.ErrNotSupported {
23+
if err != nil && err != scm.ErrNotSupported {
2424
t.Errorf("Expect Not Supported error")
2525
}
2626
}
2727

2828
func TestIssueList(t *testing.T) {
2929
_, _, err := NewDefault().Issues.List(context.Background(), "", scm.IssueListOptions{})
30-
if err != scm.ErrNotSupported {
30+
if err != nil && err != scm.ErrNotSupported {
3131
t.Errorf("Expect Not Supported error")
3232
}
3333
}
3434

3535
func TestIssueListComments(t *testing.T) {
3636
_, _, err := NewDefault().Issues.ListComments(context.Background(), "", 0, scm.ListOptions{})
37-
if err != scm.ErrNotSupported {
37+
if err != nil && err != scm.ErrNotSupported {
3838
t.Errorf("Expect Not Supported error")
3939
}
4040
}
4141

4242
func TestIssueCreate(t *testing.T) {
4343
_, _, err := NewDefault().Issues.Create(context.Background(), "", &scm.IssueInput{})
44-
if err != scm.ErrNotSupported {
44+
if err != nil && err != scm.ErrNotSupported {
4545
t.Errorf("Expect Not Supported error")
4646
}
4747
}
4848

4949
func TestIssueCreateComment(t *testing.T) {
5050
_, _, err := NewDefault().Issues.CreateComment(context.Background(), "", 0, &scm.CommentInput{})
51-
if err != scm.ErrNotSupported {
51+
if err != nil && err != scm.ErrNotSupported {
5252
t.Errorf("Expect Not Supported error")
5353
}
5454
}
5555

5656
func TestIssueCommentDelete(t *testing.T) {
5757
_, err := NewDefault().Issues.DeleteComment(context.Background(), "", 0, 0)
58-
if err != scm.ErrNotSupported {
58+
if err != nil && err != scm.ErrNotSupported {
5959
t.Errorf("Expect Not Supported error")
6060
}
6161
}
6262

6363
func TestIssueClose(t *testing.T) {
6464
_, err := NewDefault().Issues.Close(context.Background(), "", 0)
65-
if err != scm.ErrNotSupported {
65+
if err != nil && err != scm.ErrNotSupported {
6666
t.Errorf("Expect Not Supported error")
6767
}
6868
}
6969

7070
func TestIssueLock(t *testing.T) {
7171
_, err := NewDefault().Issues.Lock(context.Background(), "", 0)
72-
if err != scm.ErrNotSupported {
72+
if err != nil && err != scm.ErrNotSupported {
7373
t.Errorf("Expect Not Supported error")
7474
}
7575
}
7676

7777
func TestIssueUnlock(t *testing.T) {
7878
_, err := NewDefault().Issues.Unlock(context.Background(), "", 0)
79-
if err != scm.ErrNotSupported {
79+
if err != nil && err != scm.ErrNotSupported {
8080
t.Errorf("Expect Not Supported error")
8181
}
8282
}

scm/factory/examples/pr/main.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strconv"
88

99
"github.com/ghodss/yaml"
10+
"github.com/jenkins-x/go-scm/scm"
1011
"github.com/pkg/errors"
1112

1213
"github.com/jenkins-x/go-scm/scm/factory"
@@ -15,27 +16,46 @@ import (
1516

1617
func main() {
1718
args := os.Args
18-
if len(args) < 3 {
19+
if len(args) < 2 {
1920
fmt.Printf("usage: org/repo prNumber")
2021
return
2122
}
2223
repo := args[1]
23-
prText := args[2]
24-
number, err := strconv.Atoi(prText)
24+
25+
client, err := factory.NewClientFromEnvironment()
2526
if err != nil {
26-
helpers.Fail(errors.Wrapf(err, "failed to parse PR number: %s", prText))
27+
helpers.Fail(err)
2728
return
2829
}
30+
ctx := context.Background()
2931

30-
client, err := factory.NewClientFromEnvironment()
32+
if len(args) < 3 {
33+
fmt.Printf("Getting PRs\n")
34+
35+
prs, _, err := client.PullRequests.List(ctx, repo, scm.PullRequestListOptions{})
36+
if err != nil {
37+
helpers.Fail(err)
38+
return
39+
}
40+
for _, pr := range prs {
41+
fmt.Printf("Found PullRequest:\n")
42+
data, err := yaml.Marshal(pr)
43+
if err != nil {
44+
helpers.Fail(errors.Wrap(err, "failed to marshal PR as YAML"))
45+
return
46+
}
47+
fmt.Printf("%s:\n", string(data))
48+
}
49+
}
50+
prText := args[2]
51+
number, err := strconv.Atoi(prText)
3152
if err != nil {
32-
helpers.Fail(err)
53+
helpers.Fail(errors.Wrapf(err, "failed to parse PR number: %s", prText))
3354
return
3455
}
3556

36-
fmt.Printf("Getting PRs\n")
57+
fmt.Printf("Getting PR\n")
3758

38-
ctx := context.Background()
3959
pr, _, err := client.PullRequests.Find(ctx, repo, number)
4060
if err != nil {
4161
helpers.Fail(err)

0 commit comments

Comments
 (0)