mocks

package
v0.0.0-...-2267940 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GithubClientMock

type GithubClientMock struct {
	// CreateReleaseFunc mocks the CreateRelease method.
	CreateReleaseFunc func(opts *v66github.RepositoryRelease) (*v66github.RepositoryRelease, error)

	// EnvFunc mocks the Env method.
	EnvFunc func() providersgithub.GithubEnv

	// GetReleaseByTagFunc mocks the GetReleaseByTag method.
	GetReleaseByTagFunc func(tag string) (*v66github.RepositoryRelease, error)

	// ListBranchesFunc mocks the ListBranches method.
	ListBranchesFunc func() ([]providersgithub.Branch, error)

	// ListPullRequestCommentsFunc mocks the ListPullRequestComments method.
	ListPullRequestCommentsFunc func(prNumber int) ([]providersgithub.PullRequestComment, error)

	// PostPullRequestCommentFunc mocks the PostPullRequestComment method.
	PostPullRequestCommentFunc func(prNumber int, body string) error

	// UploadReleaseAssetFunc mocks the UploadReleaseAsset method.
	UploadReleaseAssetFunc func(releaseID int64, path string) error
	// contains filtered or unexported fields
}

GithubClientMock is a mock implementation of github.GithubClient.

func TestSomethingThatUsesGithubClient(t *testing.T) {

	// make and configure a mocked github.GithubClient
	mockedGithubClient := &GithubClientMock{
		CreateReleaseFunc: func(opts *v66github.RepositoryRelease) (*v66github.RepositoryRelease, error) {
			panic("mock out the CreateRelease method")
		},
		EnvFunc: func() providersgithub.GithubEnv {
			panic("mock out the Env method")
		},
		GetReleaseByTagFunc: func(tag string) (*v66github.RepositoryRelease, error) {
			panic("mock out the GetReleaseByTag method")
		},
		ListBranchesFunc: func() ([]providersgithub.Branch, error) {
			panic("mock out the ListBranches method")
		},
		ListPullRequestCommentsFunc: func(prNumber int) ([]providersgithub.PullRequestComment, error) {
			panic("mock out the ListPullRequestComments method")
		},
		PostPullRequestCommentFunc: func(prNumber int, body string) error {
			panic("mock out the PostPullRequestComment method")
		},
		UploadReleaseAssetFunc: func(releaseID int64, path string) error {
			panic("mock out the UploadReleaseAsset method")
		},
	}

	// use mockedGithubClient in code that requires github.GithubClient
	// and then make assertions.

}

func (*GithubClientMock) CreateRelease

CreateRelease calls CreateReleaseFunc.

func (*GithubClientMock) CreateReleaseCalls

func (mock *GithubClientMock) CreateReleaseCalls() []struct {
	Opts *v66github.RepositoryRelease
}

CreateReleaseCalls gets all the calls that were made to CreateRelease. Check the length with:

len(mockedGithubClient.CreateReleaseCalls())

func (*GithubClientMock) Env

Env calls EnvFunc.

func (*GithubClientMock) EnvCalls

func (mock *GithubClientMock) EnvCalls() []struct {
}

EnvCalls gets all the calls that were made to Env. Check the length with:

len(mockedGithubClient.EnvCalls())

func (*GithubClientMock) GetReleaseByTag

func (mock *GithubClientMock) GetReleaseByTag(tag string) (*v66github.RepositoryRelease, error)

GetReleaseByTag calls GetReleaseByTagFunc.

func (*GithubClientMock) GetReleaseByTagCalls

func (mock *GithubClientMock) GetReleaseByTagCalls() []struct {
	Tag string
}

GetReleaseByTagCalls gets all the calls that were made to GetReleaseByTag. Check the length with:

len(mockedGithubClient.GetReleaseByTagCalls())

func (*GithubClientMock) ListBranches

func (mock *GithubClientMock) ListBranches() ([]providersgithub.Branch, error)

ListBranches calls ListBranchesFunc.

func (*GithubClientMock) ListBranchesCalls

func (mock *GithubClientMock) ListBranchesCalls() []struct {
}

ListBranchesCalls gets all the calls that were made to ListBranches. Check the length with:

len(mockedGithubClient.ListBranchesCalls())

func (*GithubClientMock) ListPullRequestComments

func (mock *GithubClientMock) ListPullRequestComments(prNumber int) ([]providersgithub.PullRequestComment, error)

ListPullRequestComments calls ListPullRequestCommentsFunc.

func (*GithubClientMock) ListPullRequestCommentsCalls

func (mock *GithubClientMock) ListPullRequestCommentsCalls() []struct {
	PrNumber int
}

ListPullRequestCommentsCalls gets all the calls that were made to ListPullRequestComments. Check the length with:

len(mockedGithubClient.ListPullRequestCommentsCalls())

func (*GithubClientMock) PostPullRequestComment

func (mock *GithubClientMock) PostPullRequestComment(prNumber int, body string) error

PostPullRequestComment calls PostPullRequestCommentFunc.

func (*GithubClientMock) PostPullRequestCommentCalls

func (mock *GithubClientMock) PostPullRequestCommentCalls() []struct {
	PrNumber int
	Body     string
}

PostPullRequestCommentCalls gets all the calls that were made to PostPullRequestComment. Check the length with:

len(mockedGithubClient.PostPullRequestCommentCalls())

func (*GithubClientMock) UploadReleaseAsset

func (mock *GithubClientMock) UploadReleaseAsset(releaseID int64, path string) error

UploadReleaseAsset calls UploadReleaseAssetFunc.

func (*GithubClientMock) UploadReleaseAssetCalls

func (mock *GithubClientMock) UploadReleaseAssetCalls() []struct {
	ReleaseID int64
	Path      string
}

UploadReleaseAssetCalls gets all the calls that were made to UploadReleaseAsset. Check the length with:

len(mockedGithubClient.UploadReleaseAssetCalls())

type GithubEnvMock

type GithubEnvMock struct {
	// GetBranchFunc mocks the GetBranch method.
	GetBranchFunc func() string

	// GetEventPayloadFunc mocks the GetEventPayload method.
	GetEventPayloadFunc func() (any, error)

	// GetEventTypeFunc mocks the GetEventType method.
	GetEventTypeFunc func() string

	// GetPRNumberFunc mocks the GetPRNumber method.
	GetPRNumberFunc func() int

	// GetTagFunc mocks the GetTag method.
	GetTagFunc func() string

	// HasEventFunc mocks the HasEvent method.
	HasEventFunc func() bool

	// IsPRFunc mocks the IsPR method.
	IsPRFunc func() bool
	// contains filtered or unexported fields
}

GithubEnvMock is a mock implementation of github.GithubEnv.

func TestSomethingThatUsesGithubEnv(t *testing.T) {

	// make and configure a mocked github.GithubEnv
	mockedGithubEnv := &GithubEnvMock{
		GetBranchFunc: func() string {
			panic("mock out the GetBranch method")
		},
		GetEventPayloadFunc: func() (any, error) {
			panic("mock out the GetEventPayload method")
		},
		GetEventTypeFunc: func() string {
			panic("mock out the GetEventType method")
		},
		GetPRNumberFunc: func() int {
			panic("mock out the GetPRNumber method")
		},
		GetTagFunc: func() string {
			panic("mock out the GetTag method")
		},
		HasEventFunc: func() bool {
			panic("mock out the HasEvent method")
		},
		IsPRFunc: func() bool {
			panic("mock out the IsPR method")
		},
	}

	// use mockedGithubEnv in code that requires github.GithubEnv
	// and then make assertions.

}

func (*GithubEnvMock) GetBranch

func (mock *GithubEnvMock) GetBranch() string

GetBranch calls GetBranchFunc.

func (*GithubEnvMock) GetBranchCalls

func (mock *GithubEnvMock) GetBranchCalls() []struct {
}

GetBranchCalls gets all the calls that were made to GetBranch. Check the length with:

len(mockedGithubEnv.GetBranchCalls())

func (*GithubEnvMock) GetEventPayload

func (mock *GithubEnvMock) GetEventPayload() (any, error)

GetEventPayload calls GetEventPayloadFunc.

func (*GithubEnvMock) GetEventPayloadCalls

func (mock *GithubEnvMock) GetEventPayloadCalls() []struct {
}

GetEventPayloadCalls gets all the calls that were made to GetEventPayload. Check the length with:

len(mockedGithubEnv.GetEventPayloadCalls())

func (*GithubEnvMock) GetEventType

func (mock *GithubEnvMock) GetEventType() string

GetEventType calls GetEventTypeFunc.

func (*GithubEnvMock) GetEventTypeCalls

func (mock *GithubEnvMock) GetEventTypeCalls() []struct {
}

GetEventTypeCalls gets all the calls that were made to GetEventType. Check the length with:

len(mockedGithubEnv.GetEventTypeCalls())

func (*GithubEnvMock) GetPRNumber

func (mock *GithubEnvMock) GetPRNumber() int

GetPRNumber calls GetPRNumberFunc.

func (*GithubEnvMock) GetPRNumberCalls

func (mock *GithubEnvMock) GetPRNumberCalls() []struct {
}

GetPRNumberCalls gets all the calls that were made to GetPRNumber. Check the length with:

len(mockedGithubEnv.GetPRNumberCalls())

func (*GithubEnvMock) GetTag

func (mock *GithubEnvMock) GetTag() string

GetTag calls GetTagFunc.

func (*GithubEnvMock) GetTagCalls

func (mock *GithubEnvMock) GetTagCalls() []struct {
}

GetTagCalls gets all the calls that were made to GetTag. Check the length with:

len(mockedGithubEnv.GetTagCalls())

func (*GithubEnvMock) HasEvent

func (mock *GithubEnvMock) HasEvent() bool

HasEvent calls HasEventFunc.

func (*GithubEnvMock) HasEventCalls

func (mock *GithubEnvMock) HasEventCalls() []struct {
}

HasEventCalls gets all the calls that were made to HasEvent. Check the length with:

len(mockedGithubEnv.HasEventCalls())

func (*GithubEnvMock) IsPR

func (mock *GithubEnvMock) IsPR() bool

IsPR calls IsPRFunc.

func (*GithubEnvMock) IsPRCalls

func (mock *GithubEnvMock) IsPRCalls() []struct {
}

IsPRCalls gets all the calls that were made to IsPR. Check the length with:

len(mockedGithubEnv.IsPRCalls())

Jump to

Keyboard shortcuts

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