githubmock

package module
v0.0.0-...-2e46a69 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 21 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) 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
	// contains filtered or unexported fields
}

func NewMock

func NewMock() *Mock

func (*Mock) RegisterHandler

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

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) Head

func (pr *PullRequest) Head(repo *Repository, ref 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) Commits

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

func (*Repository) DefaultBranch

func (r *Repository) DefaultBranch(v string)

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) Tags

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

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

Jump to

Keyboard shortcuts

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