Documentation
¶
Overview ¶
Package testutil provides shared test mocks and fixtures used across multiple test packages to avoid duplication.
Index ¶
- func TestBundle() *contract.Bundle
- func TestOpenAPI() []byte
- func ValidPactoYAML() []byte
- func WriteTestBundle(t *testing.T) string
- type MockBundleStore
- func (m *MockBundleStore) ListTags(ctx context.Context, repo string) ([]string, error)
- func (m *MockBundleStore) Pull(ctx context.Context, ref string) (*contract.Bundle, error)
- func (m *MockBundleStore) Push(ctx context.Context, ref string, bundle *contract.Bundle) (string, error)
- func (m *MockBundleStore) Resolve(ctx context.Context, ref string) (string, error)
- type MockPluginRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestBundle ¶
TestBundle returns a valid in-memory Bundle for testing. The bundle includes pacto.yaml plus additional files (openapi.yaml, docs/) to verify that the full directory tree survives round-trips.
func TestOpenAPI ¶ added in v0.13.2
func TestOpenAPI() []byte
TestOpenAPI returns a minimal OpenAPI spec for testing.
func ValidPactoYAML ¶
func ValidPactoYAML() []byte
ValidPactoYAML returns a minimal valid pacto.yaml content for testing.
func WriteTestBundle ¶
WriteTestBundle creates a valid bundle directory structure in a temp dir and returns the bundle directory path. The directory includes pacto.yaml plus additional files to verify full directory tree handling.
Types ¶
type MockBundleStore ¶
type MockBundleStore struct {
PushFn func(ctx context.Context, ref string, bundle *contract.Bundle) (string, error)
PullFn func(ctx context.Context, ref string) (*contract.Bundle, error)
ResolveFn func(ctx context.Context, ref string) (string, error)
ListTagsFn func(ctx context.Context, repo string) ([]string, error)
}
MockBundleStore implements oci.BundleStore for testing.
func ErrBundleStore ¶
func ErrBundleStore(msg string) *MockBundleStore
ErrBundleStore returns a MockBundleStore where all methods return the given error.
type MockPluginRunner ¶
type MockPluginRunner struct {
RunFn func(ctx context.Context, name string, req plugin.GenerateRequest) (*plugin.GenerateResponse, error)
}
MockPluginRunner implements app.PluginRunner for testing.
func (*MockPluginRunner) Run ¶
func (m *MockPluginRunner) Run(ctx context.Context, name string, req plugin.GenerateRequest) (*plugin.GenerateResponse, error)