testing

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseTestStore added in v0.2.0

func BaseTestStore() map[string]TestResource

BaseTestStore returns a fresh store for CLI resource cmd tests.

Note: this is intentionally a function (not a var) so callers get a new map and slices each time.

func WithTestEnv added in v0.2.0

func WithTestEnv(ctx context.Context, env *TestEnv) context.Context

WithTestEnv stores a TestEnv in the context.

Types

type Hooks added in v0.2.0

type Hooks struct {
	List          func(context.Context, func(context.Context) ([]resource.Resource, error)) ([]resource.Resource, error)
	Get           func(context.Context, []string, func(context.Context, []string) ([]resource.Resource, error)) ([]resource.Resource, error)
	Create        func(context.Context, []resource.Field, func(context.Context, []resource.Field) ([]resource.Resource, error)) ([]resource.Resource, error)
	Delete        func(context.Context, []resource.Resource, func(context.Context, []resource.Resource) error) error
	OnLazyResolve func(resourceName string)
}

type TestAuthor

type TestAuthor struct {
	Name  string
	Email string
}

type TestEnv added in v0.2.0

type TestEnv struct {
	Store map[string]TestResource
	Hooks Hooks
}

TestEnv holds all test state for TestResource operations. Store it in context using WithTestEnv.

func NewTestEnv added in v0.2.0

func NewTestEnv() *TestEnv

NewTestEnv creates a new test environment with an empty store.

func (*TestEnv) Add added in v0.2.0

func (e *TestEnv) Add(r TestResource)

Add adds a TestResource to the environment's store.

func (*TestEnv) NewResource added in v0.2.0

func (e *TestEnv) NewResource() TestResource

NewResource returns a new zero-value TestResource. The actual test state is stored in context via WithTestEnv.

type TestResource

type TestResource struct {
	ID        string
	Name      string
	State     string
	URL       string
	Hidden    string
	Invisible string
	Lazy      string // Computed via callback when requested
	Settings  TestSettings
	Authors   []TestAuthor
}

func (TestResource) Create

func (TestResource) Create(ctx context.Context, fields []resource.Field) ([]resource.Resource, error)

func (TestResource) Delete

func (TestResource) Delete(ctx context.Context, targets []resource.Resource) error

func (TestResource) Edit

func (TestResource) Fields

func (t TestResource) Fields() ([]resource.Field, error)

func (TestResource) Get

func (TestResource) Get(ctx context.Context, keys []string) ([]resource.Resource, error)

func (TestResource) Key

func (t TestResource) Key() resource.Key

func (TestResource) List

func (TestResource) Raw

func (t TestResource) Raw() any

func (TestResource) Type

func (TestResource) Type() resource.Type

type TestSettings

type TestSettings struct {
	Foo int
	Bar string
}

Jump to

Keyboard shortcuts

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