fakegithub

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Bot is the exported botName
	Bot = botName
	// TestRef is the ref returned when calling GetRef
	TestRef = "abcde"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeClient

type FakeClient struct {
	Issues                     map[int]*github.Issue
	IssueID                    int
	OrgMembers                 map[string][]string
	Collaborators              []string
	IssueComments              map[int][]github.IssueComment
	IssueCommentID             int
	PullRequests               map[int]*github.PullRequest
	PullRequestChanges         map[int][]github.PullRequestChange
	PullRequestComments        map[int][]github.ReviewComment
	PullRequestReviewCommentID int
	PullRequestReviewComments  map[int][]github.ReviewComment
	ReviewID                   int
	Reviews                    map[int][]github.Review
	CombinedStatuses           map[string]*github.CombinedStatus
	CreatedStatuses            map[string][]github.Status
	IssueEvents                map[int][]github.ListedIssueEvent
	Commits                    map[string]github.RepositoryCommit

	// All Labels That Exist In The Repo
	RepoLabelsExisting []string
	// org/repo#number:label
	IssueLabelsAdded    []string
	IssueLabelsExisting []string
	IssueLabelsRemoved  []string

	// org/repo#number:body
	IssueCommentsAdded []string
	// org/repo#issuecommentid:body
	IssueCommentsEdited []string
	// org/repo#issuecommentid
	IssueCommentsDeleted []string

	// org/repo#number:body
	PullRequestReviewCommentsAdded []string

	// org/repo#issuecommentid:reaction
	IssueReactionsAdded   []string
	CommentReactionsAdded []string

	// org/repo#number:assignee
	AssigneesAdded []string

	// org/repo#number:milestone (represents the milestone for a specific issue)
	Milestone    int
	MilestoneMap map[string]int

	// list of commits for each PR
	// org/repo#number:[]commit
	CommitMap map[string][]github.RepositoryCommit

	// Fake remote git storage. File name are keys
	// and values map SHA to content
	RemoteFiles map[string]map[string]string

	// Fake remote git storage. Directory name are keys
	// and values map SHA to directory content
	RemoteDirectories map[string]map[string][]github.DirectoryContent

	// A list of refs that got deleted via DeleteRef
	RefsDeleted []struct{ Org, Repo, Ref string }

	// A map of repo names to projects
	RepoProjects map[string][]github.Project

	// A map of project name to columns
	ProjectColumnsMap map[string][]github.ProjectColumn

	// Maps column ID to the list of project cards
	ColumnCardsMap map[int][]github.ProjectCard

	// Maps project name to maps of column ID to columnName
	ColumnIDMap map[string]map[int]string

	// The project and column names for an issue or PR
	Project            string
	Column             string
	OrgRepoIssueLabels map[string][]github.Label
	OrgProjects        map[string][]github.Project

	// Maps org name to the list of hooks
	OrgHooks map[string][]github.Hook
	// Maps repo name to the list of hooks
	RepoHooks map[string][]github.Hook

	// A map of invitation id to user repository invitations
	UserRepoInvitations map[int]github.UserRepoInvitation
	// A map of organization invitations by name
	UserOrgInvitations map[string]github.UserOrgInvitation

	// Error will be returned if set. Currently only implemented for CreateStatus
	Error error

	// GetRepoError will be returned if set when GetRepo is called
	GetRepoError error

	// ListIssueCommentsWithContextError will be returned if set when ListIssueCommentsWithContext is called
	ListIssueCommentsWithContextError error

	// WasLabelAddedByHumanVal determines the return of the method with the same name
	WasLabelAddedByHumanVal bool

	// Team is a map org->teamSlug->TeamWithMembers
	Teams map[string]map[string]TeamWithMembers

	// Reviewers Requested
	ReviewersRequested []string
	// contains filtered or unexported fields
}

FakeClient is like client, but fake.

func NewFakeClient

func NewFakeClient() *FakeClient

func (*FakeClient) AcceptUserOrgInvitation

func (f *FakeClient) AcceptUserOrgInvitation(org string) error

func (*FakeClient) AcceptUserRepoInvitation

func (f *FakeClient) AcceptUserRepoInvitation(invitationID int) error

func (*FakeClient) AddLabel

func (f *FakeClient) AddLabel(owner, repo string, number int, label string) error

AddLabel adds a label

func (*FakeClient) AddLabels

func (f *FakeClient) AddLabels(owner, repo string, number int, labels ...string) error

AddLabels adds a list of labels

func (*FakeClient) AddRepoLabel

func (f *FakeClient) AddRepoLabel(org, repo, label, description, color string) error

AddRepoLabel adds a defined label given org/repo

func (*FakeClient) AssignIssue

func (f *FakeClient) AssignIssue(owner, repo string, number int, assignees []string) error

AssignIssue adds assignees.

func (*FakeClient) BotUser

func (f *FakeClient) BotUser() (*github.UserData, error)

func (*FakeClient) BotUserChecker

func (f *FakeClient) BotUserChecker() (func(candidate string) bool, error)

func (*FakeClient) BotUserCheckerWithContext

func (f *FakeClient) BotUserCheckerWithContext(_ context.Context) (func(candidate string) bool, error)

func (*FakeClient) ClearMilestone

func (f *FakeClient) ClearMilestone(org, repo string, issueNum int) error

ClearMilestone removes the milestone

func (*FakeClient) CloseIssue

func (f *FakeClient) CloseIssue(org, repo string, number int) error

func (*FakeClient) CloseIssueAsNotPlanned

func (f *FakeClient) CloseIssueAsNotPlanned(org, repo string, number int) error

func (*FakeClient) CreateComment

func (f *FakeClient) CreateComment(owner, repo string, number int, comment string) error

CreateComment adds a comment to a PR

func (*FakeClient) CreateCommentReaction

func (f *FakeClient) CreateCommentReaction(org, repo string, ID int, reaction string) error

CreateCommentReaction adds emoji to a comment.

func (*FakeClient) CreateCommentWithContext

func (f *FakeClient) CreateCommentWithContext(_ context.Context, owner, repo string, number int, comment string) error

func (*FakeClient) CreateIssue

func (f *FakeClient) CreateIssue(org, repo, title, body string, milestone int, labels, assignees []string) (int, error)

CreateIssue creates the issue.

func (*FakeClient) CreateIssueReaction

func (f *FakeClient) CreateIssueReaction(org, repo string, ID int, reaction string) error

CreateIssueReaction adds an emoji to an issue.

func (*FakeClient) CreateProjectCard

func (f *FakeClient) CreateProjectCard(org string, columnID int, projectCard github.ProjectCard) (*github.ProjectCard, error)

CreateProjectCard creates a project card under a given column.

func (*FakeClient) CreatePullRequest

func (f *FakeClient) CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (int, error)

func (*FakeClient) CreatePullRequestReviewComment

func (f *FakeClient) CreatePullRequestReviewComment(owner, repo string, number int, rc github.ReviewComment) error

CreatePullRequestReviewComment adds a comment on a PR.

func (*FakeClient) CreateReview

func (f *FakeClient) CreateReview(org, repo string, number int, r github.DraftReview) error

CreateReview adds a review to a PR

func (*FakeClient) CreateStatus

func (f *FakeClient) CreateStatus(owner, repo, SHA string, s github.Status) error

CreateStatus adds a status context to a commit.

func (*FakeClient) CreateStatusWithContext

func (f *FakeClient) CreateStatusWithContext(_ context.Context, owner, repo, SHA string, s github.Status) error

func (*FakeClient) DeleteComment

func (f *FakeClient) DeleteComment(owner, repo string, ID int) error

DeleteComment deletes a comment.

func (*FakeClient) DeleteCommentWithContext

func (f *FakeClient) DeleteCommentWithContext(_ context.Context, owner, repo string, ID int) error

func (*FakeClient) DeleteProjectCard

func (f *FakeClient) DeleteProjectCard(org string, projectCardID int) error

DeleteProjectCard deletes the project card of a specific issue or PR

func (*FakeClient) DeleteRef

func (f *FakeClient) DeleteRef(owner, repo, ref string) error

DeleteRef returns an error indicating if deletion of the given ref was successful

func (*FakeClient) DeleteStaleComments

func (f *FakeClient) DeleteStaleComments(org, repo string, number int, comments []github.IssueComment, isStale func(github.IssueComment) bool) error

DeleteStaleComments deletes comments flagged by isStale.

func (*FakeClient) EditComment

func (f *FakeClient) EditComment(org, repo string, ID int, comment string) error

EditComment edits a comment.

func (*FakeClient) EditCommentWithContext

func (f *FakeClient) EditCommentWithContext(_ context.Context, org, repo string, ID int, comment string) error

func (*FakeClient) EditIssue

func (f *FakeClient) EditIssue(org, repo string, number int, issue *github.Issue) (*github.Issue, error)

EditIssue edits the issue.

func (*FakeClient) EditPullRequest

func (f *FakeClient) EditPullRequest(org, repo string, number int, issue *github.PullRequest) (*github.PullRequest, error)

EditPullRequest edits the pull request.

func (*FakeClient) FindIssues

func (f *FakeClient) FindIssues(query, sort string, asc bool) ([]github.Issue, error)

FindIssues returns the same results as FindIssuesWithOrg

func (*FakeClient) FindIssuesWithOrg

func (f *FakeClient) FindIssuesWithOrg(org, query, sort string, asc bool) ([]github.Issue, error)

FindIssuesWithOrg returns f.Issues

func (*FakeClient) GetColumnProjectCard

func (f *FakeClient) GetColumnProjectCard(org string, columnID int, contentURL string) (*github.ProjectCard, error)

GetColumnProjectCard fetches project card if the content_url in the card matched the issue/pr

func (*FakeClient) GetColumnProjectCards

func (f *FakeClient) GetColumnProjectCards(org string, columnID int) ([]github.ProjectCard, error)

GetColumnProjectCards fetches project cards under given column

func (*FakeClient) GetCombinedStatus

func (f *FakeClient) GetCombinedStatus(owner, repo, ref string) (*github.CombinedStatus, error)

GetCombinedStatus returns the overall status for a commit.

func (*FakeClient) GetDirectory

func (f *FakeClient) GetDirectory(org, repo, dir, commit string) ([]github.DirectoryContent, error)

GetDirectory returns the contents of the file.

func (*FakeClient) GetFailedActionRunsByHeadBranch

func (f *FakeClient) GetFailedActionRunsByHeadBranch(org, repo, branchName, headSHA string) ([]github.WorkflowRun, error)

func (*FakeClient) GetFile

func (f *FakeClient) GetFile(org, repo, file, commit string) ([]byte, error)

GetFile returns the bytes of the file.

func (*FakeClient) GetIssue

func (f *FakeClient) GetIssue(owner, repo string, number int) (*github.Issue, error)

GetIssue returns the issue.

func (*FakeClient) GetIssueLabels

func (f *FakeClient) GetIssueLabels(owner, repo string, number int) ([]github.Label, error)

GetIssueLabels gets labels on an issue

func (*FakeClient) GetOrgProjects

func (f *FakeClient) GetOrgProjects(org string) ([]github.Project, error)

GetOrgProjects returns the list of projects under an org

func (*FakeClient) GetProjectColumns

func (f *FakeClient) GetProjectColumns(org string, projectID int) ([]github.ProjectColumn, error)

GetProjectColumns returns the list of columns for a given project.

func (*FakeClient) GetPullRequest

func (f *FakeClient) GetPullRequest(owner, repo string, number int) (*github.PullRequest, error)

GetPullRequest returns details about the PR.

func (*FakeClient) GetPullRequestChanges

func (f *FakeClient) GetPullRequestChanges(org, repo string, number int) ([]github.PullRequestChange, error)

GetPullRequestChanges returns the file modifications in a PR.

func (*FakeClient) GetRef

func (f *FakeClient) GetRef(owner, repo, ref string) (string, error)

GetRef returns the hash of a ref.

func (*FakeClient) GetRepo

func (f *FakeClient) GetRepo(owner, name string) (github.FullRepo, error)

func (*FakeClient) GetRepoLabels

func (f *FakeClient) GetRepoLabels(owner, repo string) ([]github.Label, error)

GetRepoLabels gets labels in a repo.

func (*FakeClient) GetRepoProjects

func (f *FakeClient) GetRepoProjects(owner, repo string) ([]github.Project, error)

GetRepoProjects returns the list of projects under a repo.

func (*FakeClient) GetRepos

func (f *FakeClient) GetRepos(org string, isUser bool) ([]github.Repo, error)

func (*FakeClient) GetSingleCommit

func (f *FakeClient) GetSingleCommit(org, repo, SHA string) (github.RepositoryCommit, error)

GetSingleCommit returns a single commit.

func (*FakeClient) GetTeamBySlug

func (f *FakeClient) GetTeamBySlug(slug string, org string) (*github.Team, error)

func (*FakeClient) IsCollaborator

func (f *FakeClient) IsCollaborator(org, repo, login string) (bool, error)

IsCollaborator returns true if the user is a collaborator of the repo.

func (*FakeClient) IsMember

func (f *FakeClient) IsMember(org, user string) (bool, error)

IsMember returns true if user is in org.

func (*FakeClient) ListCollaborators

func (f *FakeClient) ListCollaborators(org, repo string) ([]github.User, error)

ListCollaborators lists the collaborators.

func (*FakeClient) ListCurrentUserOrgInvitations

func (f *FakeClient) ListCurrentUserOrgInvitations() ([]github.UserOrgInvitation, error)

func (*FakeClient) ListCurrentUserRepoInvitations

func (f *FakeClient) ListCurrentUserRepoInvitations() ([]github.UserRepoInvitation, error)

func (*FakeClient) ListIssueComments

func (f *FakeClient) ListIssueComments(owner, repo string, number int) ([]github.IssueComment, error)

ListIssueComments returns comments.

func (*FakeClient) ListIssueCommentsWithContext

func (f *FakeClient) ListIssueCommentsWithContext(ctx context.Context, owner, repo string, number int) ([]github.IssueComment, error)

func (*FakeClient) ListIssueEvents

func (f *FakeClient) ListIssueEvents(owner, repo string, number int) ([]github.ListedIssueEvent, error)

ListIssueEvents returns issue events

func (*FakeClient) ListMilestones

func (f *FakeClient) ListMilestones(org, repo string) ([]github.Milestone, error)

ListMilestones lists milestones.

func (*FakeClient) ListOpenIssues

func (f *FakeClient) ListOpenIssues(org, repo string) ([]github.Issue, error)

ListOpenIssues returns f.issues To mock a mix of issues and pull requests, see github.Issue.PullRequest

func (*FakeClient) ListPRCommits

func (f *FakeClient) ListPRCommits(org, repo string, prNumber int) ([]github.RepositoryCommit, error)

ListPRCommits lists commits for a given PR.

func (*FakeClient) ListPullRequestComments

func (f *FakeClient) ListPullRequestComments(owner, repo string, number int) ([]github.ReviewComment, error)

ListPullRequestComments returns review comments.

func (*FakeClient) ListReviews

func (f *FakeClient) ListReviews(owner, repo string, number int) ([]github.Review, error)

ListReviews returns reviews.

func (*FakeClient) ListStatuses

func (f *FakeClient) ListStatuses(org, repo, ref string) ([]github.Status, error)

ListStatuses returns individual status contexts on a commit.

func (*FakeClient) ListTeamMembers

func (f *FakeClient) ListTeamMembers(org string, teamID int, role string) ([]github.TeamMember, error)

ListTeamMembers return a fake team with a single "sig-lead" GitHub teammember

func (*FakeClient) ListTeamMembersBySlug

func (f *FakeClient) ListTeamMembersBySlug(org, teamSlug, role string) ([]github.TeamMember, error)

ListTeamMembers return a fake team with a single "sig-lead" GitHub teammember

func (*FakeClient) ListTeams

func (f *FakeClient) ListTeams(org string) ([]github.Team, error)

ListTeams return a list of fake teams that correspond to the fake team members returned by ListTeamMembers

func (*FakeClient) MoveProjectCard

func (f *FakeClient) MoveProjectCard(org string, projectCardID int, newColumnID int) error

MoveProjectCard moves a specific project card to a specified column in the same project

func (*FakeClient) MutateWithGitHubAppsSupport

func (f *FakeClient) MutateWithGitHubAppsSupport(ctx context.Context, m interface{}, input githubql.Input, vars map[string]interface{}, org string) error

func (*FakeClient) Query

func (f *FakeClient) Query(ctx context.Context, q interface{}, vars map[string]interface{}) error

Query simply exists to allow the fake client to match the interface for packages that need it. It does not modify the passed interface at all.

func (*FakeClient) RemoveLabel

func (f *FakeClient) RemoveLabel(owner, repo string, number int, label string) error

RemoveLabel removes a label

func (*FakeClient) RequestReview

func (f *FakeClient) RequestReview(org, repo string, number int, logins []string) error

func (*FakeClient) SetMilestone

func (f *FakeClient) SetMilestone(org, repo string, issueNum, milestoneNum int) error

SetMilestone sets the milestone.

func (*FakeClient) TeamBySlugHasMember

func (f *FakeClient) TeamBySlugHasMember(org string, teamSlug string, memberLogin string) (bool, error)

func (*FakeClient) TeamHasMember

func (f *FakeClient) TeamHasMember(org string, teamID int, memberLogin string) (bool, error)

TeamHasMember checks if a user belongs to a team

func (*FakeClient) TriggerGitHubWorkflow

func (f *FakeClient) TriggerGitHubWorkflow(org, repo string, id int) error

func (*FakeClient) UpdatePullRequest

func (f *FakeClient) UpdatePullRequest(org, repo string, number int, title, body *string, open *bool, branch *string, canModify *bool) error

func (*FakeClient) WasLabelAddedByHuman

func (f *FakeClient) WasLabelAddedByHuman(_, _ string, _ int, _ string) (bool, error)

type TeamWithMembers

type TeamWithMembers struct {
	Team    github.Team
	Members sets.String
}

Jump to

Keyboard shortcuts

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