testutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Git        = "git"
	GitCliff   = "git-cliff"
	GH         = "gh"
	GLab       = "glab"
	Cog        = "cog"
	Communique = "communique"
)

Binary name constants used in contract tests.

Variables

This section is empty.

Functions

func FakeBin

func FakeBin(t *testing.T, name, script string)

FakeBin installs a shell script named `name` in a temp directory and prepends that directory to PATH for the duration of test t.

Types

type Call

type Call struct {
	Name string
	Args []string
	Env  []string // nil for Run calls; set for RunEnv calls
}

Call records a single invocation of Runner.Run or Runner.RunEnv.

type MockGenerator added in v0.3.0

type MockGenerator struct {
	CheckErr      error
	ValidateErr   error
	GenerateOut   string
	GenerateErr   error
	GenerateCalls []string // tags passed to Generate
}

MockGenerator is a port.Generator that records calls for contract testing.

func (*MockGenerator) Check added in v0.3.0

func (m *MockGenerator) Check() error

func (*MockGenerator) Generate added in v0.3.0

func (m *MockGenerator) Generate(tag string) (string, error)

func (*MockGenerator) Validate added in v0.3.0

func (m *MockGenerator) Validate() error

type MockPlatform added in v0.3.0

type MockPlatform struct {
	PlatformName     string
	CheckErr         error
	CreateReleaseErr error
	HasAssetsVal     bool
	UploadAssetsErr  error

	CreateReleaseCalls []struct{ Tag, Notes string }
	UploadAssetsCalls  []string
}

MockPlatform is a port.Platform that records calls for contract testing.

func (*MockPlatform) Check added in v0.3.0

func (m *MockPlatform) Check() error

func (*MockPlatform) CreateRelease added in v0.3.0

func (m *MockPlatform) CreateRelease(tag, notes string) error

func (*MockPlatform) HasAssets added in v0.3.0

func (m *MockPlatform) HasAssets() bool

func (*MockPlatform) Name added in v0.3.0

func (m *MockPlatform) Name() string

func (*MockPlatform) ReleaseURL added in v0.3.0

func (m *MockPlatform) ReleaseURL(tag string) string

func (*MockPlatform) UploadAssets added in v0.3.0

func (m *MockPlatform) UploadAssets(tag string) error

type MockRunner

type MockRunner struct {
	Calls []Call
	// contains filtered or unexported fields
}

MockRunner is a port.Runner that records calls and returns canned responses.

func NewMockRunner

func NewMockRunner() *MockRunner

NewMockRunner constructs an empty MockRunner.

func (*MockRunner) QueueResponse

func (m *MockRunner) QueueResponse(stdout, stderr string, err error)

QueueResponse enqueues one response to be returned by the next Run/RunEnv call.

func (*MockRunner) Run

func (m *MockRunner) Run(name string, args ...string) (string, string, error)

Run records the call and returns the next queued response.

func (*MockRunner) RunEnv

func (m *MockRunner) RunEnv(env []string, name string, args ...string) (string, string, error)

RunEnv records the call (including env) and returns the next queued response.

Jump to

Keyboard shortcuts

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