Documentation
¶
Index ¶
- Variables
- func CopyTestRepo(log fatalLogger, name string) string
- func ExecuteCommand(cmd *cobra.Command, cli string, stdout *bytes.Buffer, stderr *bytes.Buffer) (*test.CmdOut, error)
- func InitTest(m *testing.M, suffix string)
- func NewTestApiClient(t *testing.T, httpClient *http.Client, token, host string, ...) *api.Client
- func RunCommand(cmd *cobra.Command, cli string, stds ...*bytes.Buffer) (*test.CmdOut, error)
- 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) HttpClient() (*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) 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 WithGitLabClient(client *gitlab.Client) FactoryOption
- func WithHttpClientError(err error) FactoryOption
Constants ¶
This section is empty.
Variables ¶
var ( ProjectPath string GlabBinaryPath string )
Functions ¶
func CopyTestRepo ¶
func ExecuteCommand ¶
func NewTestApiClient ¶
func RunCommand ¶
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, opts ...FactoryOption) CmdExecFunc
SetupCmdForTest creates a test environment with a configured Factory
type Factory ¶
type Factory struct { ApiClientStub func(repoHost string) (*api.Client, error) HttpClientStub 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 // 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) 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) 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 WithGitLabClient ¶
func WithGitLabClient(client *gitlab.Client) FactoryOption
WithGitLabClient configures the Factory with a specific GitLab client
func WithHttpClientError ¶
func WithHttpClientError(err error) FactoryOption
WithHttpClientError configures the Factory to return an error when creating HTTP client