cmdtest

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProjectPath    string
	GlabBinaryPath string
)

Functions

func CopyTestRepo

func CopyTestRepo(log fatalLogger, name string) string

func Eq

func Eq(t *testing.T, got any, expected any)

func ExecuteCommand added in v1.25.0

func ExecuteCommand(cmd *cobra.Command, cli string, stdout *bytes.Buffer, stderr *bytes.Buffer) (*test.CmdOut, error)

func FirstLine

func FirstLine(output []byte) string

func InitIOStreams added in v1.25.0

func InitIOStreams(isTTY bool, doHyperlinks string) (*iostreams.IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)

func InitTest

func InitTest(m *testing.M, suffix string)

func RunCommand

func RunCommand(cmd *cobra.Command, cli string, stds ...*bytes.Buffer) (*test.CmdOut, error)

func StubFactory

func StubFactory(repo string, io *iostreams.IOStreams) cmdutils.Factory

func StubFactoryWithConfig

func StubFactoryWithConfig(repo string, io *iostreams.IOStreams) (cmdutils.Factory, error)

Types

type CmdExecFunc added in v1.55.0

type CmdExecFunc func(cli string) (*test.CmdOut, error)

func SetupCmdForTest added in v1.55.0

func SetupCmdForTest(t *testing.T, cmdFunc CmdFunc, opts ...FactoryOption) CmdExecFunc

SetupCmdForTest creates a test environment with a configured Factory

type CmdFunc added in v1.55.0

type CmdFunc func(cmdutils.Factory) *cobra.Command

type Factory added in v1.60.2

type Factory struct {
	HttpClientStub func() (*gitlab.Client, error)
	BaseRepoStub   func() (glrepo.Interface, error)
	RemotesStub    func() (glrepo.Remotes, error)
	ConfigStub     func() (config.Config, error)
	BranchStub     func() (string, error)
	IOStub         *iostreams.IOStreams
	// contains filtered or unexported fields
}

func InitFactory added in v1.25.0

func InitFactory(ios *iostreams.IOStreams, rt http.RoundTripper) *Factory

func NewTestFactory added in v1.60.0

func NewTestFactory(t *testing.T, ios *iostreams.IOStreams, opts ...FactoryOption) *Factory

NewTestFactory creates a Factory configured for testing with the given options

func (*Factory) BaseRepo added in v1.60.2

func (f *Factory) BaseRepo() (glrepo.Interface, error)

func (*Factory) Branch added in v1.60.2

func (f *Factory) Branch() (string, error)

func (*Factory) Config added in v1.60.2

func (f *Factory) Config() (config.Config, error)

func (*Factory) HttpClient added in v1.60.2

func (f *Factory) HttpClient() (*gitlab.Client, error)

func (*Factory) IO added in v1.60.2

func (f *Factory) IO() *iostreams.IOStreams

func (*Factory) Remotes added in v1.60.2

func (f *Factory) Remotes() (glrepo.Remotes, error)

func (*Factory) RepoOverride added in v1.60.2

func (f *Factory) RepoOverride(repo string)

type FactoryOption added in v1.55.0

type FactoryOption func(f *Factory)

FactoryOption is a function that configures a Factory

func WithBaseRepo added in v1.55.0

func WithBaseRepo(owner, repo string) FactoryOption

WithBaseRepo configures the Factory with a specific base repository

func WithBaseRepoError added in v1.60.0

func WithBaseRepoError(err error) FactoryOption

WithBaseRepoError configures the Factory to return an error when getting base repo

func WithBranch added in v1.55.0

func WithBranch(branch string) FactoryOption

WithBranch configures the Factory with a specific branch

func WithBranchError added in v1.60.0

func WithBranchError(err error) FactoryOption

WithBranchError configures the Factory to return an error when getting branch

func WithConfig added in v1.55.0

func WithConfig(cfg config.Config) FactoryOption

WithConfig configures the Factory with a specific config

func WithConfigError added in v1.55.0

func WithConfigError(err error) FactoryOption

func WithGitLabClient added in v1.55.0

func WithGitLabClient(client *gitlab.Client) FactoryOption

WithGitLabClient configures the Factory with a specific GitLab client

func WithHttpClientError added in v1.60.0

func WithHttpClientError(err error) FactoryOption

WithHttpClientError configures the Factory to return an error when creating HTTP client

Jump to

Keyboard shortcuts

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