githubmock

package module
v0.0.0-...-94e1305 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 35 Imported by: 0

README

githubmock

githubmock is a Go module for mocking GitHub API. This module provides mock library and server.

Author

Fumihiro Ito

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	// contains filtered or unexported fields
}

func NewComment

func NewComment() *Comment

func (*Comment) Author

func (c *Comment) Author(u *User) *Comment

func (*Comment) Body

func (c *Comment) Body(v string) *Comment

type Commit

type Commit struct {
	// contains filtered or unexported fields
}

func NewCommit

func NewCommit() *Commit

func (*Commit) Files

func (c *Commit) Files(files ...*File) *Commit

func (*Commit) GetSHA

func (c *Commit) GetSHA() string

func (*Commit) IsHead

func (c *Commit) IsHead() *Commit

func (*Commit) Parents

func (c *Commit) Parents(parents ...*Commit) *Commit

func (*Commit) SHA

func (c *Commit) SHA(v string) *Commit

func (*Commit) Statuses

func (c *Commit) Statuses(statuses ...*CommitStatus) *Commit

type CommitState

type CommitState string
const (
	CommitStatePending CommitState = "pending"
	CommitStateSuccess CommitState = "success"
	CommitStateFailure CommitState = "failure"
	CommitStateError   CommitState = "error"
)

type CommitStatus

type CommitStatus struct {
	State       CommitState
	Description string
}

type File

type File struct {
	Name string
	Body []byte
	// contains filtered or unexported fields
}

type Issue

type Issue struct {
	// contains filtered or unexported fields
}

func NewIssue

func NewIssue() *Issue

func (*Issue) Author

func (i *Issue) Author(u *User) *Issue

func (*Issue) Comments

func (i *Issue) Comments(comments []*Comment) *Issue

func (*Issue) CreatedAt

func (i *Issue) CreatedAt(t time.Time) *Issue

func (*Issue) Number

func (i *Issue) Number(v int) *Issue

func (*Issue) State

func (i *Issue) State(v IssueState) *Issue

func (*Issue) Title

func (i *Issue) Title(v string) *Issue

func (*Issue) UpdatedAt

func (i *Issue) UpdatedAt(t time.Time) *Issue

type IssueState

type IssueState string
const (
	IssueStateOpen   IssueState = "open"
	IssueStateClosed IssueState = "closed"
)

type Mock

type Mock struct {
	Logger    *slog.Logger
	Scheme    string
	Host      string
	Port      int
	GitHubURL string
	// contains filtered or unexported fields
}

func NewMock

func NewMock() *Mock

func (*Mock) GitHTTPHandler

func (m *Mock) GitHTTPHandler() http.Handler

GitHTTPHandler returns an http.Handler that serves repositories over the git smart HTTP protocol. It supports cloning and fetching (git-upload-pack). The handler is intended to be served on a different port than the GitHub API.

func (*Mock) LookupRepository

func (m *Mock) LookupRepository(name string) *Repository

func (*Mock) RegisterHandler

func (m *Mock) RegisterHandler(mux *http.ServeMux)

func (*Mock) Repositories

func (m *Mock) Repositories() []*Repository

func (*Mock) Repository

func (m *Mock) Repository(name string) *Repository

func (*Mock) Team

func (m *Mock) Team(slug string) *Team

func (*Mock) Transport

func (m *Mock) Transport() http.RoundTripper

func (*Mock) User

func (m *Mock) User(login string) *User

type PullRequest

type PullRequest struct {
	// contains filtered or unexported fields
}

func NewPullRequest

func NewPullRequest() *PullRequest

func (*PullRequest) Author

func (pr *PullRequest) Author(u *User) *PullRequest

func (*PullRequest) Base

func (pr *PullRequest) Base(ref string) *PullRequest

func (*PullRequest) Body

func (pr *PullRequest) Body(v string) *PullRequest

func (*PullRequest) Comments

func (pr *PullRequest) Comments(comments ...*PullRequestComment) *PullRequest

func (*PullRequest) CreatedAt

func (pr *PullRequest) CreatedAt(t time.Time) *PullRequest

func (*PullRequest) GetNumber

func (pr *PullRequest) GetNumber() int

func (*PullRequest) GetState

func (pr *PullRequest) GetState() string

func (*PullRequest) GetTitle

func (pr *PullRequest) GetTitle() string

func (*PullRequest) Head

func (pr *PullRequest) Head(repo *Repository, ref, sha string) *PullRequest

func (*PullRequest) Mergeable

func (pr *PullRequest) Mergeable() *PullRequest

func (*PullRequest) Merged

func (pr *PullRequest) Merged() *PullRequest

func (*PullRequest) Number

func (pr *PullRequest) Number(v int) *PullRequest

func (*PullRequest) Reviews

func (pr *PullRequest) Reviews(reviews ...*Review) *PullRequest

func (*PullRequest) State

func (*PullRequest) Title

func (pr *PullRequest) Title(v string) *PullRequest

func (*PullRequest) UpdatedAt

func (pr *PullRequest) UpdatedAt(t time.Time) *PullRequest

type PullRequestComment

type PullRequestComment struct {
	// contains filtered or unexported fields
}

func NewPullRequestComment

func NewPullRequestComment() *PullRequestComment

func (*PullRequestComment) Author

func (*PullRequestComment) Body

type PullRequestState

type PullRequestState string
const (
	PullRequestStateOpen   PullRequestState = "open"
	PullRequestStateClosed PullRequestState = "closed"
)

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func (*Repository) AssertPullRequest

func (r *Repository) AssertPullRequest(t *testing.T, number int) *PullRequest

func (*Repository) BuildPullRequestEvent

func (r *Repository) BuildPullRequestEvent(action string, pr *PullRequest, sender *User) *github.PullRequestEvent

func (*Repository) BuildPushEvent

func (r *Repository) BuildPushEvent(ref string, commit *Commit, sender *User) *github.PushEvent

func (*Repository) Commits

func (r *Repository) Commits(commits ...*Commit) error

func (*Repository) DefaultBranch

func (r *Repository) DefaultBranch(v string)

func (*Repository) FullName

func (r *Repository) FullName() string

func (*Repository) GetCommit

func (r *Repository) GetCommit(sha string) *Commit

func (*Repository) GetCommits

func (r *Repository) GetCommits() []*Commit

func (*Repository) GetIssue

func (r *Repository) GetIssue(num int) *Issue

func (*Repository) GetIssues

func (r *Repository) GetIssues() []*Issue

func (*Repository) GetPullRequest

func (r *Repository) GetPullRequest(num int) *PullRequest

func (*Repository) GetPullRequests

func (r *Repository) GetPullRequests() []*PullRequest

func (*Repository) Issues

func (r *Repository) Issues(issues ...*Issue)

func (*Repository) NextIndex

func (r *Repository) NextIndex() int

func (*Repository) PullRequests

func (r *Repository) PullRequests(pullRequests ...*PullRequest)

func (*Repository) SendWebhook

func (r *Repository) SendWebhook(ctx context.Context, event string, payload any) []*WebhookDelivery

func (*Repository) Tags

func (r *Repository) Tags(tags ...*Tag)

func (*Repository) Webhook

func (r *Repository) Webhook(w *Webhook) *Webhook

func (*Repository) Webhooks

func (r *Repository) Webhooks() []*Webhook

type Review

type Review struct {
	// contains filtered or unexported fields
}

func NewReview

func NewReview() *Review

func (*Review) Author

func (r *Review) Author(v string) *Review

func (*Review) Body

func (r *Review) Body(v string) *Review

func (*Review) State

func (r *Review) State(v ReviewState) *Review

func (*Review) SubmittedAt

func (r *Review) SubmittedAt(t time.Time) *Review

type ReviewState

type ReviewState string
const (
	ReviewStateChangesRequested ReviewState = "CHANGES_REQUESTED"
	ReviewStateCommented        ReviewState = "COMMENTED"
	ReviewStateApproved         ReviewState = "APPROVED"
)

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

func NewTag

func NewTag() *Tag

func (*Tag) Commit

func (t *Tag) Commit(c *Commit) *Tag

func (*Tag) Name

func (t *Tag) Name(v string) *Tag

type Team

type Team struct {
	// contains filtered or unexported fields
}

func NewTeam

func NewTeam() *Team

func (*Team) Name

func (t *Team) Name(v string) *Team

func (*Team) Slug

func (t *Team) Slug(v string) *Team

type User

type User struct {
	// contains filtered or unexported fields
}

func NewUser

func NewUser() *User

func (*User) AvatarURL

func (u *User) AvatarURL(v string) *User

func (*User) Login

func (u *User) Login(v string) *User

func (*User) Name

func (u *User) Name(v string) *User

func (*User) Team

func (u *User) Team(slug string) *User

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook() *Webhook

func (*Webhook) Events

func (w *Webhook) Events(events ...string) *Webhook

func (*Webhook) GetEvents

func (w *Webhook) GetEvents() []string

func (*Webhook) GetURL

func (w *Webhook) GetURL() string

func (*Webhook) Secret

func (w *Webhook) Secret(v string) *Webhook

func (*Webhook) URL

func (w *Webhook) URL(v string) *Webhook

type WebhookDelivery

type WebhookDelivery struct {
	URL        string
	StatusCode int
	Err        error
}

Jump to

Keyboard shortcuts

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