Skip to content

Commit

Permalink
Merge pull request drone#33 from jstrachan/stuff
Browse files Browse the repository at this point in the history
fix: avoid failures on bitbucket cluster
  • Loading branch information
jenkins-x-bot authored Oct 2, 2019
2 parents f4dbd5f + 4a1196d commit 210d615
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 35 deletions.
50 changes: 33 additions & 17 deletions scm/driver/bitbucket/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,86 @@ type issueService struct {
}

func (s *issueService) Search(context.Context, scm.SearchOptions) ([]*scm.SearchIssue, *scm.Response, error) {
// TODO implemment
// TODO implement
return nil, nil, nil
}

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

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

func (s *issueService) ListEvents(context.Context, string, int, scm.ListOptions) ([]*scm.ListedIssueEvent, *scm.Response, error) {
panic("implement me")
// TODO implement
return nil, nil, nil
}

func (s *issueService) ListLabels(context.Context, string, int, scm.ListOptions) ([]*scm.Label, *scm.Response, error) {
panic("implement me")
// TODO implement
return nil, nil, nil
}

func (s *issueService) AddLabel(ctx context.Context, repo string, number int, label string) (*scm.Response, error) {
return nil, scm.ErrNotSupported
// TODO implement
return nil, nil
}

func (s *issueService) DeleteLabel(ctx context.Context, repo string, number int, label string) (*scm.Response, error) {
return nil, scm.ErrNotSupported
// TODO implement
return nil, nil
}

func (s *issueService) Find(ctx context.Context, repo string, number int) (*scm.Issue, *scm.Response, error) {
return nil, nil, scm.ErrNotSupported
// TODO implement
return nil, nil, nil
}

func (s *issueService) FindComment(ctx context.Context, repo string, index, id int) (*scm.Comment, *scm.Response, error) {
return nil, nil, scm.ErrNotSupported
// TODO implement
return nil, nil, nil
}

func (s *issueService) List(ctx context.Context, repo string, opts scm.IssueListOptions) ([]*scm.Issue, *scm.Response, error) {
return nil, nil, scm.ErrNotSupported
// TODO implement
return nil, nil, nil
}

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

func (s *issueService) Create(ctx context.Context, repo string, input *scm.IssueInput) (*scm.Issue, *scm.Response, error) {
return nil, nil, scm.ErrNotSupported
// TODO implement
return nil, nil, nil
}

func (s *issueService) CreateComment(ctx context.Context, repo string, number int, input *scm.CommentInput) (*scm.Comment, *scm.Response, error) {
return nil, nil, scm.ErrNotSupported
// TODO implement
return nil, nil, nil
}

func (s *issueService) DeleteComment(ctx context.Context, repo string, number, id int) (*scm.Response, error) {
return nil, scm.ErrNotSupported
// TODO implement
return nil, nil
}

func (s *issueService) Close(ctx context.Context, repo string, number int) (*scm.Response, error) {
return nil, scm.ErrNotSupported
// TODO implement
return nil, nil
}

func (s *issueService) Lock(ctx context.Context, repo string, number int) (*scm.Response, error) {
return nil, scm.ErrNotSupported
// TODO implement
return nil, nil
}

func (s *issueService) Unlock(ctx context.Context, repo string, number int) (*scm.Response, error) {
return nil, scm.ErrNotSupported
// TODO implement
return nil, nil
}
20 changes: 10 additions & 10 deletions scm/driver/bitbucket/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,70 @@ import (

func TestIssueFind(t *testing.T) {
_, _, err := NewDefault().Issues.Find(context.Background(), "", 0)
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueCommentFind(t *testing.T) {
_, _, err := NewDefault().Issues.FindComment(context.Background(), "", 0, 0)
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueList(t *testing.T) {
_, _, err := NewDefault().Issues.List(context.Background(), "", scm.IssueListOptions{})
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueListComments(t *testing.T) {
_, _, err := NewDefault().Issues.ListComments(context.Background(), "", 0, scm.ListOptions{})
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueCreate(t *testing.T) {
_, _, err := NewDefault().Issues.Create(context.Background(), "", &scm.IssueInput{})
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueCreateComment(t *testing.T) {
_, _, err := NewDefault().Issues.CreateComment(context.Background(), "", 0, &scm.CommentInput{})
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueCommentDelete(t *testing.T) {
_, err := NewDefault().Issues.DeleteComment(context.Background(), "", 0, 0)
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueClose(t *testing.T) {
_, err := NewDefault().Issues.Close(context.Background(), "", 0)
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueLock(t *testing.T) {
_, err := NewDefault().Issues.Lock(context.Background(), "", 0)
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}

func TestIssueUnlock(t *testing.T) {
_, err := NewDefault().Issues.Unlock(context.Background(), "", 0)
if err != scm.ErrNotSupported {
if err != nil && err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
}
}
36 changes: 28 additions & 8 deletions scm/factory/examples/pr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"

"github.com/ghodss/yaml"
"github.com/jenkins-x/go-scm/scm"
"github.com/pkg/errors"

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

func main() {
args := os.Args
if len(args) < 3 {
if len(args) < 2 {
fmt.Printf("usage: org/repo prNumber")
return
}
repo := args[1]
prText := args[2]
number, err := strconv.Atoi(prText)

client, err := factory.NewClientFromEnvironment()
if err != nil {
helpers.Fail(errors.Wrapf(err, "failed to parse PR number: %s", prText))
helpers.Fail(err)
return
}
ctx := context.Background()

client, err := factory.NewClientFromEnvironment()
if len(args) < 3 {
fmt.Printf("Getting PRs\n")

prs, _, err := client.PullRequests.List(ctx, repo, scm.PullRequestListOptions{})
if err != nil {
helpers.Fail(err)
return
}
for _, pr := range prs {
fmt.Printf("Found PullRequest:\n")
data, err := yaml.Marshal(pr)
if err != nil {
helpers.Fail(errors.Wrap(err, "failed to marshal PR as YAML"))
return
}
fmt.Printf("%s:\n", string(data))
}
}
prText := args[2]
number, err := strconv.Atoi(prText)
if err != nil {
helpers.Fail(err)
helpers.Fail(errors.Wrapf(err, "failed to parse PR number: %s", prText))
return
}

fmt.Printf("Getting PRs\n")
fmt.Printf("Getting PR\n")

ctx := context.Background()
pr, _, err := client.PullRequests.Find(ctx, repo, number)
if err != nil {
helpers.Fail(err)
Expand Down

0 comments on commit 210d615

Please sign in to comment.