Documentation
¶
Index ¶
- func BaseTestStore() map[string]TestResource
- func WithTestEnv(ctx context.Context, env *TestEnv) context.Context
- type Hooks
- type TestAuthor
- type TestEnv
- type TestResource
- func (TestResource) Create(ctx context.Context, fields []resource.Field) ([]resource.Resource, error)
- func (TestResource) Delete(ctx context.Context, targets []resource.Resource) error
- func (TestResource) Edit(ctx context.Context, target resource.Resource, fields []resource.Field) (resource.Resource, error)
- func (t TestResource) Fields() ([]resource.Field, error)
- func (TestResource) Get(ctx context.Context, keys []string) ([]resource.Resource, error)
- func (t TestResource) Key() resource.Key
- func (TestResource) List(ctx context.Context) ([]resource.Resource, error)
- func (t TestResource) Raw() any
- func (TestResource) Type() resource.Type
- type TestSettings
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.
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 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) Key ¶
func (t TestResource) Key() resource.Key
func (TestResource) Raw ¶
func (t TestResource) Raw() any
func (TestResource) Type ¶
func (TestResource) Type() resource.Type
type TestSettings ¶
Click to show internal directories.
Click to hide internal directories.