Documentation
¶
Overview ¶
Package cmdtest is a generated GoMock package.
Index ¶
- Variables
- func CopyTestRepo(log fatalLogger, name string) string
- func InitTest(m *testing.M, suffix string)
- func NewTestApiClient(t *testing.T, httpClient *http.Client, token, host string, ...) *api.Client
- func NewTestOAuth2ApiClient(t *testing.T, httpClient *http.Client, tokenSource oauth2.TokenSource, ...) *api.Client
- func SliceMatch[T any](elements ...any) gomock.Matcher
- func TestIOStreams(options ...iostreams.IOStreamsOption) (*iostreams.IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)
- func WithTestIOStreamsAsTTY(asTTY bool) iostreams.IOStreamsOption
- type CmdExecFunc
- type CmdFunc
- type Factory
- func (f *Factory) ApiClient(repoHost string) (*api.Client, error)
- func (f *Factory) BaseRepo() (glrepo.Interface, error)
- func (f *Factory) Branch() (string, error)
- func (f *Factory) BuildInfo() api.BuildInfo
- func (f *Factory) Config() config.Config
- func (f *Factory) DefaultHostname() string
- func (f *Factory) Executor() cmdutils.Executor
- func (f *Factory) GitLabClient() (*gitlab.Client, error)
- func (f *Factory) IO() *iostreams.IOStreams
- func (f *Factory) Remotes() (glrepo.Remotes, error)
- func (f *Factory) RepoOverride(repo string) error
- type FactoryOption
- func WithApiClient(client *api.Client) FactoryOption
- func WithBaseRepo(owner, repo string, hostname string) FactoryOption
- func WithBaseRepoError(err error) FactoryOption
- func WithBranch(branch string) FactoryOption
- func WithBranchError(err error) FactoryOption
- func WithBuildInfo(buildInfo api.BuildInfo) FactoryOption
- func WithConfig(cfg config.Config) FactoryOption
- func WithExecutor(exec cmdutils.Executor) FactoryOption
- func WithGitLabClient(client *gitlab.Client) FactoryOption
- func WithGitLabClientError(err error) FactoryOption
- func WithIOStreamsOverride(ios *iostreams.IOStreams) FactoryOption
- func WithResponder(t *testing.T, responder *huhtest.Responder) FactoryOption
- func WithStdin(stdin string) FactoryOption
- type MockExecutor
- func (m *MockExecutor) EXPECT() *MockExecutorMockRecorder
- func (m *MockExecutor) Exec(ctx context.Context, name string, args []string, env map[string]string) error
- func (m *MockExecutor) ExecWithCombinedOutput(ctx context.Context, name string, args []string, env map[string]string) ([]byte, error)
- func (m *MockExecutor) ExecWithIO(ctx context.Context, name string, args []string, env map[string]string, ...) error
- func (m *MockExecutor) LookPath(file string) (string, error)
- type MockExecutorExecCall
- func (c *MockExecutorExecCall) Do(f func(context.Context, string, []string, map[string]string) error) *MockExecutorExecCall
- func (c *MockExecutorExecCall) DoAndReturn(f func(context.Context, string, []string, map[string]string) error) *MockExecutorExecCall
- func (c *MockExecutorExecCall) Return(arg0 error) *MockExecutorExecCall
- type MockExecutorExecWithCombinedOutputCall
- func (c *MockExecutorExecWithCombinedOutputCall) Do(f func(context.Context, string, []string, map[string]string) ([]byte, error)) *MockExecutorExecWithCombinedOutputCall
- func (c *MockExecutorExecWithCombinedOutputCall) DoAndReturn(f func(context.Context, string, []string, map[string]string) ([]byte, error)) *MockExecutorExecWithCombinedOutputCall
- func (c *MockExecutorExecWithCombinedOutputCall) Return(arg0 []byte, arg1 error) *MockExecutorExecWithCombinedOutputCall
- type MockExecutorExecWithIOCall
- type MockExecutorLookPathCall
- type MockExecutorMockRecorder
- func (mr *MockExecutorMockRecorder) Exec(ctx, name, args, env any) *MockExecutorExecCall
- func (mr *MockExecutorMockRecorder) ExecWithCombinedOutput(ctx, name, args, env any) *MockExecutorExecWithCombinedOutputCall
- func (mr *MockExecutorMockRecorder) ExecWithIO(ctx, name, args, env, stdin, stdout, stderr any) *MockExecutorExecWithIOCall
- func (mr *MockExecutorMockRecorder) LookPath(file any) *MockExecutorLookPathCall
Constants ¶
This section is empty.
Variables ¶
var ( ProjectPath string GlabBinaryPath string )
Functions ¶
func CopyTestRepo ¶
func NewTestApiClient ¶
func NewTestOAuth2ApiClient ¶ added in v1.75.0
func SliceMatch ¶ added in v1.81.0
SliceMatch returns a matcher that matches a []T slice element-by-element. Elements can be values of type T (exact match) or gomock.Matcher instances.
func TestIOStreams ¶
func WithTestIOStreamsAsTTY ¶
func WithTestIOStreamsAsTTY(asTTY bool) iostreams.IOStreamsOption
WithTestIOStreamsAsTTY sets stdin, stdout and stderr as TTY By default they are not treated as TTYs. This will overwrite the behavior for the three of them. If you only want to set a specific one, use iostreams.WithStdin, iostreams.WithStdout or iostreams.WithStderr.
Types ¶
type CmdExecFunc ¶
func SetupCmdForTest ¶
func SetupCmdForTest(t *testing.T, cmdFunc CmdFunc, isTTY bool, opts ...FactoryOption) CmdExecFunc
SetupCmdForTest creates a test environment with a configured Factory
type Factory ¶
type Factory struct {
ApiClientStub func(repoHost string) (*api.Client, error)
GitLabClientStub func() (*gitlab.Client, error)
BaseRepoStub func() (glrepo.Interface, error)
RemotesStub func() (glrepo.Remotes, error)
ConfigStub func() config.Config
BranchStub func() (string, error)
IOStub *iostreams.IOStreams
BuildInfoStub api.BuildInfo
ExecutorStub cmdutils.Executor
// contains filtered or unexported fields
}
func NewTestFactory ¶
func NewTestFactory(ios *iostreams.IOStreams, opts ...FactoryOption) *Factory
NewTestFactory creates a Factory configured for testing with the given options
func (*Factory) DefaultHostname ¶
func (*Factory) GitLabClient ¶ added in v1.66.0
func (*Factory) RepoOverride ¶
type FactoryOption ¶
type FactoryOption func(f *Factory)
FactoryOption is a function that configures a Factory
func WithApiClient ¶
func WithApiClient(client *api.Client) FactoryOption
WithApiClient configures the Factory with a specific API client
func WithBaseRepo ¶
func WithBaseRepo(owner, repo string, hostname string) FactoryOption
WithBaseRepo configures the Factory with a specific base repository
func WithBaseRepoError ¶
func WithBaseRepoError(err error) FactoryOption
WithBaseRepoError configures the Factory to return an error when getting base repo
func WithBranch ¶
func WithBranch(branch string) FactoryOption
WithBranch configures the Factory with a specific branch
func WithBranchError ¶
func WithBranchError(err error) FactoryOption
WithBranchError configures the Factory to return an error when getting branch
func WithBuildInfo ¶
func WithBuildInfo(buildInfo api.BuildInfo) FactoryOption
WithBuildInfo configures the Factory build information
func WithConfig ¶
func WithConfig(cfg config.Config) FactoryOption
WithConfig configures the Factory with a specific config
func WithExecutor ¶ added in v1.81.0
func WithExecutor(exec cmdutils.Executor) FactoryOption
func WithGitLabClient ¶
func WithGitLabClient(client *gitlab.Client) FactoryOption
WithGitLabClient configures the Factory with a specific GitLab client
func WithGitLabClientError ¶ added in v1.66.0
func WithGitLabClientError(err error) FactoryOption
WithGitLabClientError configures the Factory to return an error when creating GitLab client
func WithIOStreamsOverride ¶ added in v1.81.0
func WithIOStreamsOverride(ios *iostreams.IOStreams) FactoryOption
WithIOStreamsOverride configures an IOStreams instance for testing
Attention: only use as a last resort and prefer functions like WithStdin etc to configure the IOStreams that's already created.
func WithResponder ¶ added in v1.73.0
func WithResponder(t *testing.T, responder *huhtest.Responder) FactoryOption
func WithStdin ¶ added in v1.75.0
func WithStdin(stdin string) FactoryOption
WithStdin configures the Factory with specific stdin content
type MockExecutor ¶ added in v1.81.0
type MockExecutor struct {
// contains filtered or unexported fields
}
MockExecutor is a mock of Executor interface.
func NewMockExecutor ¶ added in v1.81.0
func NewMockExecutor(ctrl *gomock.Controller) *MockExecutor
NewMockExecutor creates a new mock instance.
func (*MockExecutor) EXPECT ¶ added in v1.81.0
func (m *MockExecutor) EXPECT() *MockExecutorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockExecutor) Exec ¶ added in v1.81.0
func (m *MockExecutor) Exec(ctx context.Context, name string, args []string, env map[string]string) error
Exec mocks base method.
func (*MockExecutor) ExecWithCombinedOutput ¶ added in v1.81.0
func (m *MockExecutor) ExecWithCombinedOutput(ctx context.Context, name string, args []string, env map[string]string) ([]byte, error)
ExecWithCombinedOutput mocks base method.
type MockExecutorExecCall ¶ added in v1.81.0
MockExecutorExecCall wrap *gomock.Call
func (*MockExecutorExecCall) Do ¶ added in v1.81.0
func (c *MockExecutorExecCall) Do(f func(context.Context, string, []string, map[string]string) error) *MockExecutorExecCall
Do rewrite *gomock.Call.Do
func (*MockExecutorExecCall) DoAndReturn ¶ added in v1.81.0
func (c *MockExecutorExecCall) DoAndReturn(f func(context.Context, string, []string, map[string]string) error) *MockExecutorExecCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockExecutorExecCall) Return ¶ added in v1.81.0
func (c *MockExecutorExecCall) Return(arg0 error) *MockExecutorExecCall
Return rewrite *gomock.Call.Return
type MockExecutorExecWithCombinedOutputCall ¶ added in v1.81.0
MockExecutorExecWithCombinedOutputCall wrap *gomock.Call
func (*MockExecutorExecWithCombinedOutputCall) Do ¶ added in v1.81.0
func (c *MockExecutorExecWithCombinedOutputCall) Do(f func(context.Context, string, []string, map[string]string) ([]byte, error)) *MockExecutorExecWithCombinedOutputCall
Do rewrite *gomock.Call.Do
func (*MockExecutorExecWithCombinedOutputCall) DoAndReturn ¶ added in v1.81.0
func (c *MockExecutorExecWithCombinedOutputCall) DoAndReturn(f func(context.Context, string, []string, map[string]string) ([]byte, error)) *MockExecutorExecWithCombinedOutputCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockExecutorExecWithCombinedOutputCall) Return ¶ added in v1.81.0
func (c *MockExecutorExecWithCombinedOutputCall) Return(arg0 []byte, arg1 error) *MockExecutorExecWithCombinedOutputCall
Return rewrite *gomock.Call.Return
type MockExecutorExecWithIOCall ¶ added in v1.81.0
MockExecutorExecWithIOCall wrap *gomock.Call
func (*MockExecutorExecWithIOCall) Do ¶ added in v1.81.0
func (c *MockExecutorExecWithIOCall) Do(f func(context.Context, string, []string, map[string]string, io.Reader, io.Writer, io.Writer) error) *MockExecutorExecWithIOCall
Do rewrite *gomock.Call.Do
func (*MockExecutorExecWithIOCall) DoAndReturn ¶ added in v1.81.0
func (c *MockExecutorExecWithIOCall) DoAndReturn(f func(context.Context, string, []string, map[string]string, io.Reader, io.Writer, io.Writer) error) *MockExecutorExecWithIOCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockExecutorExecWithIOCall) Return ¶ added in v1.81.0
func (c *MockExecutorExecWithIOCall) Return(arg0 error) *MockExecutorExecWithIOCall
Return rewrite *gomock.Call.Return
type MockExecutorLookPathCall ¶ added in v1.81.0
MockExecutorLookPathCall wrap *gomock.Call
func (*MockExecutorLookPathCall) Do ¶ added in v1.81.0
func (c *MockExecutorLookPathCall) Do(f func(string) (string, error)) *MockExecutorLookPathCall
Do rewrite *gomock.Call.Do
func (*MockExecutorLookPathCall) DoAndReturn ¶ added in v1.81.0
func (c *MockExecutorLookPathCall) DoAndReturn(f func(string) (string, error)) *MockExecutorLookPathCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockExecutorLookPathCall) Return ¶ added in v1.81.0
func (c *MockExecutorLookPathCall) Return(arg0 string, arg1 error) *MockExecutorLookPathCall
Return rewrite *gomock.Call.Return
type MockExecutorMockRecorder ¶ added in v1.81.0
type MockExecutorMockRecorder struct {
// contains filtered or unexported fields
}
MockExecutorMockRecorder is the mock recorder for MockExecutor.
func (*MockExecutorMockRecorder) Exec ¶ added in v1.81.0
func (mr *MockExecutorMockRecorder) Exec(ctx, name, args, env any) *MockExecutorExecCall
Exec indicates an expected call of Exec.
func (*MockExecutorMockRecorder) ExecWithCombinedOutput ¶ added in v1.81.0
func (mr *MockExecutorMockRecorder) ExecWithCombinedOutput(ctx, name, args, env any) *MockExecutorExecWithCombinedOutputCall
ExecWithCombinedOutput indicates an expected call of ExecWithCombinedOutput.
func (*MockExecutorMockRecorder) ExecWithIO ¶ added in v1.81.0
func (mr *MockExecutorMockRecorder) ExecWithIO(ctx, name, args, env, stdin, stdout, stderr any) *MockExecutorExecWithIOCall
ExecWithIO indicates an expected call of ExecWithIO.
func (*MockExecutorMockRecorder) LookPath ¶ added in v1.81.0
func (mr *MockExecutorMockRecorder) LookPath(file any) *MockExecutorLookPathCall
LookPath indicates an expected call of LookPath.