Skip to content

Commit

Permalink
Merge pull request drone#49 from wlynch/fake
Browse files Browse the repository at this point in the history
feat: Implement CreateStatus, return PR labels in fake.
  • Loading branch information
jenkins-x-bot committed Nov 6, 2019
2 parents e4a40b2 + ccc8f6e commit 6c4b4d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions scm/driver/fake/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func (s *pullService) Find(ctx context.Context, repo string, number int) (*scm.P
if !exists {
return nil, nil, fmt.Errorf("Pull request number %d does not exit", number)
}
if labels, _, err := s.client.Issues.ListLabels(ctx, repo, number, scm.ListOptions{}); err == nil {
val.Labels = labels
}
return val, nil, nil
}

Expand Down
17 changes: 15 additions & 2 deletions scm/driver/fake/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,21 @@ func (s *repositoryService) CreateHook(context.Context, string, *scm.HookInput)
panic("implement me")
}

func (s *repositoryService) CreateStatus(context.Context, string, string, *scm.StatusInput) (*scm.Status, *scm.Response, error) {
panic("implement me")
func (s *repositoryService) CreateStatus(ctx context.Context, repo string, ref string, in *scm.StatusInput) (*scm.Status, *scm.Response, error) {
statuses := s.data.Statuses[ref]
if statuses == nil {
statuses = []*scm.Status{}
}
status := scm.ConvertStatusInputToStatus(in)
for _, existing := range statuses {
if existing.Label == status.Label {
*existing = *status
return status, nil, nil
}
}
statuses = append(statuses, status)
s.data.Statuses[ref] = statuses
return status, nil, nil
}

func (s *repositoryService) DeleteHook(context.Context, string, string) (*scm.Response, error) {
Expand Down

0 comments on commit 6c4b4d8

Please sign in to comment.