Skip to content

Commit

Permalink
added FindCommit to fake provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Jul 9, 2019
1 parent 2412aa1 commit e6dd7d3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scm/driver/fake/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Data struct {
//CombinedStatuses map[string]*github.CombinedStatus
CreatedStatuses map[string][]scm.Status
IssueEvents map[int][]*scm.ListedIssueEvent
Commits map[string]scm.CommitTree
Commits map[string]*scm.Commit

//All Labels That Exist In The Repo
RepoLabelsExisting []string
Expand Down Expand Up @@ -67,7 +67,7 @@ func NewData() *Data {
Reviews: map[int][]*scm.Review{},
CreatedStatuses: map[string][]scm.Status{},
IssueEvents: map[int][]*scm.ListedIssueEvent{},
Commits: map[string]scm.CommitTree{},
Commits: map[string]*scm.Commit{},
MilestoneMap: map[string]int{},
CommitMap: map[string][]scm.Commit{},
RemoteFiles: map[string]map[string]string{},
Expand Down
4 changes: 2 additions & 2 deletions scm/driver/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func NewDefault() (*scm.Client, *Data) {
// initialize services
client.Driver = scm.DriverFake

client.Repositories = &repositoryService{client: client, data: data}
client.Git = &gitService{client: client, data: data}
client.Issues = &issueService{client: client, data: data}
client.PullRequests = &pullService{client: client, data: data}
client.Repositories = &repositoryService{client: client, data: data}
client.Reviews = &reviewService{client: client, data: data}

// TODO
/*
client.Contents = &contentService{client}
client.Git = &gitService{client}
client.Organizations = &organizationService{client}
client.Users = &userService{client}
client.Webhooks = &webhookService{client}
Expand Down
41 changes: 41 additions & 0 deletions scm/driver/fake/git.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package fake

import (
"context"

"github.com/jenkins-x/go-scm/scm"
)

type gitService struct {
client *wrapper
data *Data
}

func (s *gitService) FindBranch(ctx context.Context, repo, name string) (*scm.Reference, *scm.Response, error) {
panic("implement me")
}

func (s *gitService) FindCommit(ctx context.Context, repo, SHA string) (*scm.Commit, *scm.Response, error) {
f := s.data
return f.Commits[SHA], nil, nil
}

func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Reference, *scm.Response, error) {
panic("implement me")
}

func (s *gitService) ListBranches(ctx context.Context, repo string, opts scm.ListOptions) ([]*scm.Reference, *scm.Response, error) {
panic("implement me")
}

func (s *gitService) ListCommits(ctx context.Context, repo string, opts scm.CommitListOptions) ([]*scm.Commit, *scm.Response, error) {
panic("implement me")
}

func (s *gitService) ListChanges(ctx context.Context, repo, ref string, opts scm.ListOptions) ([]*scm.Change, *scm.Response, error) {
panic("implement me")
}

func (s *gitService) ListTags(ctx context.Context, repo string, opts scm.ListOptions) ([]*scm.Reference, *scm.Response, error) {
panic("implement me")
}

0 comments on commit e6dd7d3

Please sign in to comment.