usecasetest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package usecasetest provides test helpers for the generic usecase package

Package usecasetest Usecase test utils

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertListResults

func AssertListResults[R, I resource.Resource](
	t *testing.T,
	uc usecase.Lister[R],
	testDef UsecaseListerTestDef[R],
	assertResultFn func(t *testing.T, expect, actual R, opts ...resourcetest.AssertOption),
	assertIncludeFn func(t *testing.T, expect, actual I, opts ...resourcetest.AssertOption),
)

Types

type Creator

type Creator[R resource.Resource] struct {
	mock.Mock
}

Creator is an autogenerated mock type for the Creator type

func NewCreator

func NewCreator[R resource.Resource](t interface {
	mock.TestingT
	Cleanup(func())
}) *Creator[R]

NewCreator creates a new instance of Creator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Creator[R]) Create

func (_mock *Creator[R]) Create(ctx context.Context, r R) (R, error)

Create provides a mock function for the type Creator

func (*Creator[R]) EXPECT

func (_m *Creator[R]) EXPECT() *Creator_Expecter[R]

type CreatorBatch

type CreatorBatch[R resource.Resource] struct {
	mock.Mock
}

CreatorBatch is an autogenerated mock type for the CreatorBatch type

func NewCreatorBatch

func NewCreatorBatch[R resource.Resource](t interface {
	mock.TestingT
	Cleanup(func())
}) *CreatorBatch[R]

NewCreatorBatch creates a new instance of CreatorBatch. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*CreatorBatch[R]) CreateBatch

func (_mock *CreatorBatch[R]) CreateBatch(ctx context.Context, r []R) ([]R, error)

CreateBatch provides a mock function for the type CreatorBatch

func (*CreatorBatch[R]) EXPECT

func (_m *CreatorBatch[R]) EXPECT() *CreatorBatch_Expecter[R]

type CreatorBatch_CreateBatch_Call

type CreatorBatch_CreateBatch_Call[R resource.Resource] struct {
	*mock.Call
}

CreatorBatch_CreateBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateBatch'

func (*CreatorBatch_CreateBatch_Call[R]) Return

func (_c *CreatorBatch_CreateBatch_Call[R]) Return(vs []R, err error) *CreatorBatch_CreateBatch_Call[R]

func (*CreatorBatch_CreateBatch_Call[R]) Run

func (_c *CreatorBatch_CreateBatch_Call[R]) Run(run func(ctx context.Context, r []R)) *CreatorBatch_CreateBatch_Call[R]

func (*CreatorBatch_CreateBatch_Call[R]) RunAndReturn

func (_c *CreatorBatch_CreateBatch_Call[R]) RunAndReturn(run func(ctx context.Context, r []R) ([]R, error)) *CreatorBatch_CreateBatch_Call[R]

type CreatorBatch_Expecter

type CreatorBatch_Expecter[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func (*CreatorBatch_Expecter[R]) CreateBatch

func (_e *CreatorBatch_Expecter[R]) CreateBatch(ctx interface{}, r interface{}) *CreatorBatch_CreateBatch_Call[R]

CreateBatch is a helper method to define mock.On call

  • ctx context.Context
  • r []R

type Creator_Create_Call

type Creator_Create_Call[R resource.Resource] struct {
	*mock.Call
}

Creator_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'

func (*Creator_Create_Call[R]) Return

func (_c *Creator_Create_Call[R]) Return(v R, err error) *Creator_Create_Call[R]

func (*Creator_Create_Call[R]) Run

func (_c *Creator_Create_Call[R]) Run(run func(ctx context.Context, r R)) *Creator_Create_Call[R]

func (*Creator_Create_Call[R]) RunAndReturn

func (_c *Creator_Create_Call[R]) RunAndReturn(run func(ctx context.Context, r R) (R, error)) *Creator_Create_Call[R]

type Creator_Expecter

type Creator_Expecter[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func (*Creator_Expecter[R]) Create

func (_e *Creator_Expecter[R]) Create(ctx interface{}, r interface{}) *Creator_Create_Call[R]

Create is a helper method to define mock.On call

  • ctx context.Context
  • r R

type Deleter

type Deleter struct {
	mock.Mock
}

Deleter is an autogenerated mock type for the Deleter type

func NewDeleter

func NewDeleter(t interface {
	mock.TestingT
	Cleanup(func())
}) *Deleter

NewDeleter creates a new instance of Deleter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Deleter) Delete

func (_mock *Deleter) Delete(context1 context.Context, deleteType repository.DeleteType, options ...search.Option) error

Delete provides a mock function for the type Deleter

func (*Deleter) EXPECT

func (_m *Deleter) EXPECT() *Deleter_Expecter

type Deleter_Delete_Call

type Deleter_Delete_Call struct {
	*mock.Call
}

Deleter_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete'

func (*Deleter_Delete_Call) Return

func (*Deleter_Delete_Call) Run

func (_c *Deleter_Delete_Call) Run(run func(context1 context.Context, deleteType repository.DeleteType, options ...search.Option)) *Deleter_Delete_Call

func (*Deleter_Delete_Call) RunAndReturn

func (_c *Deleter_Delete_Call) RunAndReturn(run func(context1 context.Context, deleteType repository.DeleteType, options ...search.Option) error) *Deleter_Delete_Call

type Deleter_Expecter

type Deleter_Expecter struct {
	// contains filtered or unexported fields
}

func (*Deleter_Expecter) Delete

func (_e *Deleter_Expecter) Delete(context1 interface{}, deleteType interface{}, options ...interface{}) *Deleter_Delete_Call

Delete is a helper method to define mock.On call

  • context1 context.Context
  • deleteType repository.DeleteType
  • options ...search.Option

type Getter

type Getter[R resource.Resource] struct {
	mock.Mock
}

Getter is an autogenerated mock type for the Getter type

func NewGetter

func NewGetter[R resource.Resource](t interface {
	mock.TestingT
	Cleanup(func())
}) *Getter[R]

NewGetter creates a new instance of Getter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Getter[R]) EXPECT

func (_m *Getter[R]) EXPECT() *Getter_Expecter[R]

func (*Getter[R]) Get

func (_mock *Getter[R]) Get(ctx context.Context, opts ...search.Option) (R, error)

Get provides a mock function for the type Getter

type GetterStub

type GetterStub[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func NewGetterStub

func NewGetterStub[R resource.Resource](res R, err error, opts ...StubOption) *GetterStub[R]

func (*GetterStub[R]) Get

func (gs *GetterStub[R]) Get(ctx context.Context, opts ...search.Option) (R, error)

type Getter_Expecter

type Getter_Expecter[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func (*Getter_Expecter[R]) Get

func (_e *Getter_Expecter[R]) Get(ctx interface{}, opts ...interface{}) *Getter_Get_Call[R]

Get is a helper method to define mock.On call

  • ctx context.Context
  • opts ...search.Option

type Getter_Get_Call

type Getter_Get_Call[R resource.Resource] struct {
	*mock.Call
}

Getter_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'

func (*Getter_Get_Call[R]) Return

func (_c *Getter_Get_Call[R]) Return(v R, err error) *Getter_Get_Call[R]

func (*Getter_Get_Call[R]) Run

func (_c *Getter_Get_Call[R]) Run(run func(ctx context.Context, opts ...search.Option)) *Getter_Get_Call[R]

func (*Getter_Get_Call[R]) RunAndReturn

func (_c *Getter_Get_Call[R]) RunAndReturn(run func(ctx context.Context, opts ...search.Option) (R, error)) *Getter_Get_Call[R]

type Lister

type Lister[R resource.Resource] struct {
	mock.Mock
}

Lister is an autogenerated mock type for the Lister type

func NewLister

func NewLister[R resource.Resource](t interface {
	mock.TestingT
	Cleanup(func())
}) *Lister[R]

NewLister creates a new instance of Lister. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Lister[R]) EXPECT

func (_m *Lister[R]) EXPECT() *Lister_Expecter[R]

func (*Lister[R]) List

func (_mock *Lister[R]) List(ctx context.Context, opts ...search.Option) (resource.ListResponse[R], error)

List provides a mock function for the type Lister

type ListerStub

type ListerStub[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func NewListerStub

func NewListerStub[R resource.Resource](res resource.ListResponse[R], err error, opts ...StubOption) *ListerStub[R]

func (*ListerStub[R]) List

func (ls *ListerStub[R]) List(ctx context.Context, opts ...search.Option) (resource.ListResponse[R], error)

type Lister_Expecter

type Lister_Expecter[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func (*Lister_Expecter[R]) List

func (_e *Lister_Expecter[R]) List(ctx interface{}, opts ...interface{}) *Lister_List_Call[R]

List is a helper method to define mock.On call

  • ctx context.Context
  • opts ...search.Option

type Lister_List_Call

type Lister_List_Call[R resource.Resource] struct {
	*mock.Call
}

Lister_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'

func (*Lister_List_Call[R]) Return

func (_c *Lister_List_Call[R]) Return(listResponse resource.ListResponse[R], err error) *Lister_List_Call[R]

func (*Lister_List_Call[R]) Run

func (_c *Lister_List_Call[R]) Run(run func(ctx context.Context, opts ...search.Option)) *Lister_List_Call[R]

func (*Lister_List_Call[R]) RunAndReturn

func (_c *Lister_List_Call[R]) RunAndReturn(run func(ctx context.Context, opts ...search.Option) (resource.ListResponse[R], error)) *Lister_List_Call[R]

type Patcher

type Patcher[R any] struct {
	mock.Mock
}

Patcher is an autogenerated mock type for the Patcher type

func NewPatcher

func NewPatcher[R any](t interface {
	mock.TestingT
	Cleanup(func())
}) *Patcher[R]

NewPatcher creates a new instance of Patcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Patcher[R]) EXPECT

func (_m *Patcher[R]) EXPECT() *Patcher_Expecter[R]

func (*Patcher[R]) Patch

func (_mock *Patcher[R]) Patch(ctx context.Context, opts ...repository.PatchOption) (R, error)

Patch provides a mock function for the type Patcher

type PatcherBatch

type PatcherBatch[T resource.Resource, R resource.Resource] struct {
	mock.Mock
}

PatcherBatch is an autogenerated mock type for the PatcherBatch type

func NewPatcherBatch

func NewPatcherBatch[T resource.Resource, R resource.Resource](t interface {
	mock.TestingT
	Cleanup(func())
}) *PatcherBatch[T, R]

NewPatcherBatch creates a new instance of PatcherBatch. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*PatcherBatch[T, R]) EXPECT

func (_m *PatcherBatch[T, R]) EXPECT() *PatcherBatch_Expecter[T, R]

func (*PatcherBatch[T, R]) PatchBatch

func (_m *PatcherBatch[T, R]) PatchBatch(ctx context.Context, req T) ([]R, error)

PatchBatch provides a mock function with given fields: ctx, req

type PatcherBatch_Expecter

type PatcherBatch_Expecter[T resource.Resource, R resource.Resource] struct {
	// contains filtered or unexported fields
}

func (*PatcherBatch_Expecter[T, R]) PatchBatch

func (_e *PatcherBatch_Expecter[T, R]) PatchBatch(ctx interface{}, req interface{}) *PatcherBatch_PatchBatch_Call[T, R]

PatchBatch is a helper method to define mock.On call

  • ctx context.Context
  • req T

type PatcherBatch_PatchBatch_Call

type PatcherBatch_PatchBatch_Call[T resource.Resource, R resource.Resource] struct {
	*mock.Call
}

PatcherBatch_PatchBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PatchBatch'

func (*PatcherBatch_PatchBatch_Call[T, R]) Return

func (_c *PatcherBatch_PatchBatch_Call[T, R]) Return(_a0 []R, _a1 error) *PatcherBatch_PatchBatch_Call[T, R]

func (*PatcherBatch_PatchBatch_Call[T, R]) Run

func (_c *PatcherBatch_PatchBatch_Call[T, R]) Run(run func(ctx context.Context, req T)) *PatcherBatch_PatchBatch_Call[T, R]

func (*PatcherBatch_PatchBatch_Call[T, R]) RunAndReturn

func (_c *PatcherBatch_PatchBatch_Call[T, R]) RunAndReturn(run func(context.Context, T) ([]R, error)) *PatcherBatch_PatchBatch_Call[T, R]

type Patcher_Expecter

type Patcher_Expecter[R any] struct {
	// contains filtered or unexported fields
}

func (*Patcher_Expecter[R]) Patch

func (_e *Patcher_Expecter[R]) Patch(ctx interface{}, opts ...interface{}) *Patcher_Patch_Call[R]

Patch is a helper method to define mock.On call

  • ctx context.Context
  • opts ...repository.PatchOption

type Patcher_Patch_Call

type Patcher_Patch_Call[R any] struct {
	*mock.Call
}

Patcher_Patch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Patch'

func (*Patcher_Patch_Call[R]) Return

func (_c *Patcher_Patch_Call[R]) Return(v R, err error) *Patcher_Patch_Call[R]

func (*Patcher_Patch_Call[R]) Run

func (_c *Patcher_Patch_Call[R]) Run(run func(ctx context.Context, opts ...repository.PatchOption)) *Patcher_Patch_Call[R]

func (*Patcher_Patch_Call[R]) RunAndReturn

func (_c *Patcher_Patch_Call[R]) RunAndReturn(run func(ctx context.Context, opts ...repository.PatchOption) (R, error)) *Patcher_Patch_Call[R]

type StubOption

type StubOption func(c *stubConfig)

func WithStubInterceptor

func WithStubInterceptor(f func(ctx context.Context, opts ...search.Option)) StubOption

type Updater

type Updater[R resource.Resource] struct {
	mock.Mock
}

Updater is an autogenerated mock type for the Updater type

func NewUpdater

func NewUpdater[R resource.Resource](t interface {
	mock.TestingT
	Cleanup(func())
}) *Updater[R]

NewUpdater creates a new instance of Updater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Updater[R]) EXPECT

func (_m *Updater[R]) EXPECT() *Updater_Expecter[R]

func (*Updater[R]) Update

func (_mock *Updater[R]) Update(ctx context.Context, req R) (R, error)

Update provides a mock function for the type Updater

type Updater_Expecter

type Updater_Expecter[R resource.Resource] struct {
	// contains filtered or unexported fields
}

func (*Updater_Expecter[R]) Update

func (_e *Updater_Expecter[R]) Update(ctx interface{}, req interface{}) *Updater_Update_Call[R]

Update is a helper method to define mock.On call

  • ctx context.Context
  • req R

type Updater_Update_Call

type Updater_Update_Call[R resource.Resource] struct {
	*mock.Call
}

Updater_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update'

func (*Updater_Update_Call[R]) Return

func (_c *Updater_Update_Call[R]) Return(v R, err error) *Updater_Update_Call[R]

func (*Updater_Update_Call[R]) Run

func (_c *Updater_Update_Call[R]) Run(run func(ctx context.Context, req R)) *Updater_Update_Call[R]

func (*Updater_Update_Call[R]) RunAndReturn

func (_c *Updater_Update_Call[R]) RunAndReturn(run func(ctx context.Context, req R) (R, error)) *Updater_Update_Call[R]

type UsecaseListerTestDef

type UsecaseListerTestDef[R resource.Resource] struct {
	Ctx       context.Context
	SearchOpt []search.Option
	Want      resource.ListResponse[R]
	WantErr   error
}

Jump to

Keyboard shortcuts

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