mocks

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mocks provides mock implementations for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DisplayMessage

type DisplayMessage struct {
	Level   string
	Message string
}

DisplayMessage represents a logged message with its level.

type GitHubAPIClient

type GitHubAPIClient struct {

	// Configurable responses
	SetRepositoryFromURLError      error
	ListLabelsResponse             []*ghpkg.Label
	ListLabelsError                error
	CreatePullRequestResponse      *github.PullRequest
	CreatePullRequestError         error
	GetPullRequestByBranchResponse *github.PullRequest
	GetPullRequestByBranchError    error
	WaitForWorkflowsConclusion     string
	WaitForWorkflowsError          error
	MergePullRequestError          error
	GetPullRequestsByHeadResponse  []*github.PullRequest
	GetPullRequestsByHeadError     error
	DeleteBranchError              error
	// contains filtered or unexported fields
}

GitHubAPIClient is a mock implementation of github.APIClient with call tracking.

func NewGitHubAPIClient

func NewGitHubAPIClient() *GitHubAPIClient

NewGitHubAPIClient creates a new mock GitHub API client.

func (*GitHubAPIClient) CreatePullRequest

func (m *GitHubAPIClient) CreatePullRequest(
	head, base, title, body string,
	assignees, reviewers, labels []string,
) (*github.PullRequest, error)

CreatePullRequest implements github.APIClient.

func (*GitHubAPIClient) DeleteBranch

func (m *GitHubAPIClient) DeleteBranch(branch string) error

DeleteBranch implements github.APIClient.

func (*GitHubAPIClient) GetCallCount

func (m *GitHubAPIClient) GetCallCount(method string) int

GetCallCount returns the number of times a method was called.

func (*GitHubAPIClient) GetCalls

func (m *GitHubAPIClient) GetCalls() []MethodCall

GetCalls returns all tracked method calls.

func (*GitHubAPIClient) GetLastCall

func (m *GitHubAPIClient) GetLastCall(method string) *MethodCall

GetLastCall returns the last call to the specified method, or nil if not called.

func (*GitHubAPIClient) GetPullRequestByBranch

func (m *GitHubAPIClient) GetPullRequestByBranch(head, base string) (*github.PullRequest, error)

GetPullRequestByBranch implements github.APIClient.

func (*GitHubAPIClient) GetPullRequestsByHead

func (m *GitHubAPIClient) GetPullRequestsByHead(head string) ([]*github.PullRequest, error)

GetPullRequestsByHead implements github.APIClient.

func (*GitHubAPIClient) ListLabels

func (m *GitHubAPIClient) ListLabels() ([]*ghpkg.Label, error)

ListLabels implements github.APIClient.

func (*GitHubAPIClient) MergePullRequest

func (m *GitHubAPIClient) MergePullRequest(prNumber int, mergeMethod, commitTitle, commitBody string) error

MergePullRequest implements github.APIClient.

func (*GitHubAPIClient) Reset

func (m *GitHubAPIClient) Reset()

Reset clears all tracked calls.

func (*GitHubAPIClient) SetRepositoryFromURL

func (m *GitHubAPIClient) SetRepositoryFromURL(url string) error

SetRepositoryFromURL implements github.APIClient.

func (*GitHubAPIClient) WaitForWorkflows

func (m *GitHubAPIClient) WaitForWorkflows(timeout time.Duration) (string, error)

WaitForWorkflows implements github.APIClient.

type GitLabAPIClient

type GitLabAPIClient struct {

	// Configurable responses
	SetProjectFromURLError           error
	ListLabelsResponse               []*glpkg.Label
	ListLabelsError                  error
	CreateMergeRequestResponse       *gitlab.MergeRequest
	CreateMergeRequestError          error
	GetMergeRequestByBranchResponse  *gitlab.MergeRequest
	GetMergeRequestByBranchError     error
	WaitForPipelineStatus            string
	WaitForPipelineError             error
	ApproveMergeRequestError         error
	MergeMergeRequestError           error
	GetMergeRequestsByBranchResponse []*gitlab.BasicMergeRequest
	GetMergeRequestsByBranchError    error
	// contains filtered or unexported fields
}

GitLabAPIClient is a mock implementation of gitlab.APIClient with call tracking.

func NewGitLabAPIClient

func NewGitLabAPIClient() *GitLabAPIClient

NewGitLabAPIClient creates a new mock GitLab API client.

func (*GitLabAPIClient) ApproveMergeRequest

func (m *GitLabAPIClient) ApproveMergeRequest(mrIID int) error

ApproveMergeRequest implements gitlab.APIClient.

func (*GitLabAPIClient) CreateMergeRequest

func (m *GitLabAPIClient) CreateMergeRequest(
	sourceBranch, targetBranch, title, description, assignee, reviewer string,
	labels []string, squash bool,
) (*gitlab.MergeRequest, error)

CreateMergeRequest implements gitlab.APIClient.

func (*GitLabAPIClient) GetCallCount

func (m *GitLabAPIClient) GetCallCount(method string) int

GetCallCount returns the number of times a method was called.

func (*GitLabAPIClient) GetCalls

func (m *GitLabAPIClient) GetCalls() []MethodCall

GetCalls returns all tracked method calls.

func (*GitLabAPIClient) GetLastCall

func (m *GitLabAPIClient) GetLastCall(method string) *MethodCall

GetLastCall returns the last call to the specified method, or nil if not called.

func (*GitLabAPIClient) GetMergeRequestByBranch

func (m *GitLabAPIClient) GetMergeRequestByBranch(sourceBranch, targetBranch string) (*gitlab.MergeRequest, error)

GetMergeRequestByBranch implements gitlab.APIClient.

func (*GitLabAPIClient) GetMergeRequestsByBranch

func (m *GitLabAPIClient) GetMergeRequestsByBranch(sourceBranch string) ([]*gitlab.BasicMergeRequest, error)

GetMergeRequestsByBranch implements gitlab.APIClient.

func (*GitLabAPIClient) ListLabels

func (m *GitLabAPIClient) ListLabels() ([]*glpkg.Label, error)

ListLabels implements gitlab.APIClient.

func (*GitLabAPIClient) MergeMergeRequest

func (m *GitLabAPIClient) MergeMergeRequest(mrIID int, squash bool) error

MergeMergeRequest implements gitlab.APIClient.

func (*GitLabAPIClient) Reset

func (m *GitLabAPIClient) Reset()

Reset clears all tracked calls.

func (*GitLabAPIClient) SetProjectFromURL

func (m *GitLabAPIClient) SetProjectFromURL(url string) error

SetProjectFromURL implements gitlab.APIClient.

func (*GitLabAPIClient) WaitForPipeline

func (m *GitLabAPIClient) WaitForPipeline(timeout time.Duration) (string, error)

WaitForPipeline implements gitlab.APIClient.

type MethodCall

type MethodCall struct {
	Method string
	Args   map[string]any
}

MethodCall represents a tracked method call with its parameters.

type MockCommitRetriever added in v0.6.0

type MockCommitRetriever struct {
	GetCommitsResponse []commits.Commit
	GetCommitsError    error
	CallHistory        []string
	CallCount          map[string]int
}

MockCommitRetriever is a mock implementation of commits.CommitRetriever for testing.

func NewMockCommitRetriever added in v0.6.0

func NewMockCommitRetriever() *MockCommitRetriever

NewMockCommitRetriever creates a new mock commit retriever.

func (*MockCommitRetriever) GetCallCountFor added in v0.6.0

func (m *MockCommitRetriever) GetCallCountFor(method string) int

GetCallCountFor returns the number of times a method was called.

func (*MockCommitRetriever) GetCommits added in v0.6.0

func (m *MockCommitRetriever) GetCommits(branch string) ([]commits.Commit, error)

GetCommits implements commits.CommitRetriever interface.

func (*MockCommitRetriever) GetLastCall added in v0.6.0

func (m *MockCommitRetriever) GetLastCall() string

GetLastCall returns the last method call recorded.

type MockDisplayRenderer

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

MockDisplayRenderer is a mock implementation of DisplayRenderer for testing.

func NewMockDisplayRenderer

func NewMockDisplayRenderer() *MockDisplayRenderer

NewMockDisplayRenderer creates a new mock display renderer.

func (*MockDisplayRenderer) Debug

func (m *MockDisplayRenderer) Debug(message string)

Debug implements DisplayRenderer.

func (*MockDisplayRenderer) DecreasePadding

func (m *MockDisplayRenderer) DecreasePadding()

DecreasePadding implements DisplayRenderer.

func (*MockDisplayRenderer) Error

func (m *MockDisplayRenderer) Error(message string)

Error implements DisplayRenderer.

func (*MockDisplayRenderer) GetMessages

func (m *MockDisplayRenderer) GetMessages() []DisplayMessage

GetMessages returns all tracked messages.

func (*MockDisplayRenderer) GetMessagesByLevel

func (m *MockDisplayRenderer) GetMessagesByLevel(level string) []string

GetMessagesByLevel returns all messages of a specific level.

func (*MockDisplayRenderer) IncreasePadding

func (m *MockDisplayRenderer) IncreasePadding()

IncreasePadding implements DisplayRenderer.

func (*MockDisplayRenderer) Info

func (m *MockDisplayRenderer) Info(message string)

Info implements DisplayRenderer.

func (*MockDisplayRenderer) InfoHandle

func (m *MockDisplayRenderer) InfoHandle(message string) *bullets.BulletHandle

InfoHandle implements DisplayRenderer.

func (*MockDisplayRenderer) Reset

func (m *MockDisplayRenderer) Reset()

Reset clears all tracked messages.

func (*MockDisplayRenderer) SpinnerCircle

func (m *MockDisplayRenderer) SpinnerCircle(message string) *bullets.Spinner

SpinnerCircle implements DisplayRenderer.

func (*MockDisplayRenderer) String

func (m *MockDisplayRenderer) String() string

String returns a formatted representation of all messages for debugging.

func (*MockDisplayRenderer) Success

func (m *MockDisplayRenderer) Success(message string)

Success implements DisplayRenderer.

type MockMessageSelector added in v0.6.0

type MockMessageSelector struct {
	GetMessageForMRResponse commits.MessageSelection
	GetMessageForMRError    error
	CallHistory             []string
	CallCount               map[string]int
}

MockMessageSelector is a mock implementation of commits.MessageSelector for testing.

func NewMockMessageSelector added in v0.6.0

func NewMockMessageSelector() *MockMessageSelector

NewMockMessageSelector creates a new mock message selector.

func (*MockMessageSelector) GetCallCountFor added in v0.6.0

func (m *MockMessageSelector) GetCallCountFor(method string) int

GetCallCountFor returns the number of times a method was called.

func (*MockMessageSelector) GetLastCall added in v0.6.0

func (m *MockMessageSelector) GetLastCall() string

GetLastCall returns the last method call recorded.

func (*MockMessageSelector) GetMessageForMR added in v0.6.0

func (m *MockMessageSelector) GetMessageForMR(_ []commits.Commit, _ string) (commits.MessageSelection, error)

GetMessageForMR implements commits.MessageSelector interface.

type MockSelectionRenderer added in v0.6.0

type MockSelectionRenderer struct {
	DisplaySelectionPromptResponse int
	DisplaySelectionPromptError    error
	CallHistory                    []string
	CallCount                      map[string]int
}

MockSelectionRenderer is a mock implementation of commits.SelectionRenderer for testing.

func NewMockSelectionRenderer added in v0.6.0

func NewMockSelectionRenderer() *MockSelectionRenderer

NewMockSelectionRenderer creates a new mock selection renderer.

func (*MockSelectionRenderer) DisplaySelectionPrompt added in v0.6.0

func (m *MockSelectionRenderer) DisplaySelectionPrompt(_ []commits.Commit) (int, error)

DisplaySelectionPrompt implements commits.SelectionRenderer interface.

func (*MockSelectionRenderer) GetCallCountFor added in v0.6.0

func (m *MockSelectionRenderer) GetCallCountFor(method string) int

GetCallCountFor returns the number of times a method was called.

func (*MockSelectionRenderer) GetLastCall added in v0.6.0

func (m *MockSelectionRenderer) GetLastCall() string

GetLastCall returns the last method call recorded.

Jump to

Keyboard shortcuts

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