Skip to content

Commit

Permalink
Merge pull request drone#47 from wlynch/fake
Browse files Browse the repository at this point in the history
fix: Add fake implementation for Status operations.
  • Loading branch information
jenkins-x-bot authored Oct 31, 2019
2 parents d4071f8 + a9918dc commit 8c87898
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 5 additions & 7 deletions scm/driver/fake/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ type Data struct {
PullRequestComments map[int][]*scm.Comment
ReviewID int
Reviews map[int][]*scm.Review
// TODO
//CombinedStatuses map[string]*github.CombinedStatus
CreatedStatuses map[string][]scm.Status
IssueEvents map[int][]*scm.ListedIssueEvent
Commits map[string]*scm.Commit
TestRef string
Statuses map[string][]*scm.Status
IssueEvents map[int][]*scm.ListedIssueEvent
Commits map[string]*scm.Commit
TestRef string

//All Labels That Exist In The Repo
RepoLabelsExisting []string
Expand Down Expand Up @@ -72,7 +70,7 @@ func NewData() *Data {
PullRequestChanges: map[int][]*scm.Change{},
PullRequestComments: map[int][]*scm.Comment{},
Reviews: map[int][]*scm.Review{},
CreatedStatuses: map[string][]scm.Status{},
Statuses: map[string][]*scm.Status{},
IssueEvents: map[int][]*scm.ListedIssueEvent{},
Commits: map[string]*scm.Commit{},
MilestoneMap: map[string]int{},
Expand Down
18 changes: 15 additions & 3 deletions scm/driver/fake/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ type repositoryService struct {
}

func (s *repositoryService) FindCombinedStatus(ctx context.Context, repo, ref string) (*scm.CombinedStatus, *scm.Response, error) {
panic("implement me")
statuses, _, err := s.ListStatus(ctx, repo, ref, scm.ListOptions{})
if err != nil {
return nil, nil, err
}
return &scm.CombinedStatus{
Sha: ref,
Statuses: statuses,
}, nil, nil
}

func (s *repositoryService) FindUserPermission(ctx context.Context, repo string, user string) (string, *scm.Response, error) {
Expand Down Expand Up @@ -78,8 +85,13 @@ func (s *repositoryService) ListHooks(context.Context, string, scm.ListOptions)
panic("implement me")
}

func (s *repositoryService) ListStatus(context.Context, string, string, scm.ListOptions) ([]*scm.Status, *scm.Response, error) {
panic("implement me")
func (s *repositoryService) ListStatus(ctx context.Context, repo string, ref string, opt scm.ListOptions) ([]*scm.Status, *scm.Response, error) {
f := s.data
result := make([]*scm.Status, 0, len(f.Statuses))
for _, status := range f.Statuses[ref] {
result = append(result, status)
}
return result, nil, nil
}

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

0 comments on commit 8c87898

Please sign in to comment.