testutil

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared test mocks and fixtures used across multiple test packages to avoid duplication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestBundle

func TestBundle() *contract.Bundle

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

func WriteTestBundle(t *testing.T) string

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.

func (*MockBundleStore) ListTags added in v0.5.7

func (m *MockBundleStore) ListTags(ctx context.Context, repo string) ([]string, error)

func (*MockBundleStore) Pull

func (m *MockBundleStore) Pull(ctx context.Context, ref string) (*contract.Bundle, error)

func (*MockBundleStore) Push

func (m *MockBundleStore) Push(ctx context.Context, ref string, bundle *contract.Bundle) (string, error)

func (*MockBundleStore) Resolve

func (m *MockBundleStore) Resolve(ctx context.Context, ref string) (string, 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

Jump to

Keyboard shortcuts

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