fakeghutil

package
v0.0.0-...-7cc1d6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeGithubClient

type FakeGithubClient struct {
	User         *github.User
	Repos        []string
	Issues       map[string]map[int]*github.Issue       // map of repo: map of issueNumber: issues
	Comments     map[int]map[int64]*github.IssueComment // map of issueNumber: map of commentID: comments
	PullRequests map[string]map[int]*github.PullRequest // map of repo: map of PullRequest Number: pullrequests
	PRCommits    map[int][]*github.RepositoryCommit     // map of PR number: slice of commits
	CommitFiles  map[string][]*github.CommitFile        // map of commit SHA: slice of files

	NextNumber int    // number to be assigned to next newly created issue/comment
	BaseURL    string // base URL of Github
}

FakeGithubClient is a faked client, implements all functions of ghutil.GithubOperations

func NewFakeGithubClient

func NewFakeGithubClient() *FakeGithubClient

NewFakeGithubClient creates a FakeGithubClient and initialize it's maps

func (*FakeGithubClient) AddCommitToPullRequest

func (fgc *FakeGithubClient) AddCommitToPullRequest(org, repo string, ID int, SHA string) error

AddCommitToPullRequest adds commit to pullrequest This is complementary of mocking CreatePullRequest, so that newly created pull request can have commits

func (*FakeGithubClient) AddFileToCommit

func (fgc *FakeGithubClient) AddFileToCommit(org, repo, SHA, filename, patch string) error

AddFileToCommit adds file to commit This is complementary of mocking CreatePullRequest, so that newly created pull request can have files

func (*FakeGithubClient) AddLabelsToIssue

func (fgc *FakeGithubClient) AddLabelsToIssue(org, repo string, issueNumber int, labels []string) error

AddLabelsToIssue adds label on issue

func (*FakeGithubClient) CloseIssue

func (fgc *FakeGithubClient) CloseIssue(org, repo string, issueNumber int) error

CloseIssue closes issue

func (*FakeGithubClient) CreateComment

func (fgc *FakeGithubClient) CreateComment(org, repo string, issueNumber int, commentBody string) (*github.IssueComment, error)

CreateComment adds comment to issue

func (*FakeGithubClient) CreateIssue

func (fgc *FakeGithubClient) CreateIssue(org, repo, title, body string) (*github.Issue, error)

CreateIssue creates issue

func (*FakeGithubClient) CreatePullRequest

func (fgc *FakeGithubClient) CreatePullRequest(org, repo, head, base, title, body string) (*github.PullRequest, error)

CreatePullRequest creates PullRequest, passing head user and branch name "user:ref-name", and base branch name like "master"

func (*FakeGithubClient) DeleteComment

func (fgc *FakeGithubClient) DeleteComment(org, repo string, commentID int64) error

DeleteComment deletes comment from issue

func (*FakeGithubClient) EditComment

func (fgc *FakeGithubClient) EditComment(org, repo string, commentID int64, commentBody string) error

EditComment edits comment by replacing with provided comment

func (*FakeGithubClient) EditPullRequest

func (fgc *FakeGithubClient) EditPullRequest(org, repo string, ID int, title, body string) (*github.PullRequest, error)

EditPullRequest updates PullRequest

func (*FakeGithubClient) GetComment

func (fgc *FakeGithubClient) GetComment(org, repo string, commentID int64) (*github.IssueComment, error)

GetComment gets comment by comment ID

func (*FakeGithubClient) GetGithubUser

func (fgc *FakeGithubClient) GetGithubUser() (*github.User, error)

GetGithubUser gets current authenticated user

func (*FakeGithubClient) GetPullRequest

func (fgc *FakeGithubClient) GetPullRequest(org, repo string, ID int) (*github.PullRequest, error)

GetPullRequest gets PullRequest by ID

func (*FakeGithubClient) GetPullRequestByCommitID

func (fgc *FakeGithubClient) GetPullRequestByCommitID(org, repo string, commitID string) (*github.PullRequest, error)

GetPullRequestByCommitID gets PullRequest by commit ID

func (*FakeGithubClient) ListComments

func (fgc *FakeGithubClient) ListComments(org, repo string, issueNumber int) ([]*github.IssueComment, error)

ListComments gets all comments from issue

func (*FakeGithubClient) ListCommits

func (fgc *FakeGithubClient) ListCommits(org, repo string, ID int) ([]*github.RepositoryCommit, error)

ListCommits lists commits from a pull request

func (*FakeGithubClient) ListFiles

func (fgc *FakeGithubClient) ListFiles(org, repo string, ID int) ([]*github.CommitFile, error)

ListFiles lists files from a pull request

func (*FakeGithubClient) ListIssuesByRepo

func (fgc *FakeGithubClient) ListIssuesByRepo(org, repo string, labels []string) ([]*github.Issue, error)

ListIssuesByRepo lists issues within given repo, filters by labels if provided

func (*FakeGithubClient) ListPullRequests

func (fgc *FakeGithubClient) ListPullRequests(org, repo, head, base string) ([]*github.PullRequest, error)

ListPullRequests lists pull requests within given repo, filters by head user and branch name if provided as "user:ref-name", and by base name if provided, i.e. "master"

func (*FakeGithubClient) ListRepos

func (fgc *FakeGithubClient) ListRepos(org string) ([]string, error)

ListRepos lists repos under org

func (*FakeGithubClient) RemoveLabelForIssue

func (fgc *FakeGithubClient) RemoveLabelForIssue(org, repo string, issueNumber int, label string) error

RemoveLabelForIssue removes given label for issue

func (*FakeGithubClient) ReopenIssue

func (fgc *FakeGithubClient) ReopenIssue(org, repo string, issueNumber int) error

ReopenIssue reopen issue

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL