Documentation
¶
Index ¶
- func AllDeleter[Entity, ID any](subject allDeleterSubjectResource[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func AllFinder[Entity, ID any](subject crud.AllFinder[Entity], opts ...Option[Entity, ID]) contract.Contract
- func ByIDDeleter[Entity, ID any](subject crd[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func ByIDFinder[Entity, ID any](subject crud.ByIDFinder[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func ByIDsFinder[Entity, ID any](subject crud.ByIDsFinder[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func Creator[Entity, ID any](subject crd[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func Deleter[Entity, ID any](subject deleterSubject[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func Finder[Entity, ID any](subject subjectFinder[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func OnePhaseCommitProtocol[Entity, ID any](subject crd[Entity, ID], manager comproto.OnePhaseCommitProtocol, ...) contract.Contract
- func Purger[Entity, ID any](subject purgerSubjectResource[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func QueryMany[Entity, ID any](subject any, query QueryManyFunc[Entity], ...) contract.Contract
- func QueryOne[Entity, ID any](subject any, query QueryOneFunc[Entity], opts ...Option[Entity, ID]) contract.Contract
- func Updater[Entity, ID any](ssubject subjectUpdater[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- type Config
- type Contract
- type Option
- type QueryManyFunc
- type QueryOneFunc
- type TestingTBContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDeleter ¶
func AllFinder ¶
func AllFinder[Entity, ID any](subject crud.AllFinder[Entity], opts ...Option[Entity, ID]) contract.Contract
AllFinder can return business entities from a given resource that implement it's test The "EntityTypeName" is an Empty struct for the specific entity (struct) type that should be returned.
NewEntityForTest used only for testing and should not be provided outside of testing
func ByIDDeleter ¶
func ByIDFinder ¶
func ByIDsFinder ¶
func OnePhaseCommitProtocol ¶
Types ¶
type Config ¶
type Config[ENT, ID any] struct { // MakeContext is responsible to return back a backgrond context for testing with the crud contract subject. MakeContext func() context.Context // MakeEntity is responsible to create a populated Entity. MakeEntity func(testing.TB) ENT // SupportIDReuse is an optional configuration value that tells the contract // that recreating an entity with an ID which belongs to a previously deleted entity is accepted. SupportIDReuse bool // SupportRecreate is an optional configuration value that tells the contract // that deleting an Entity then recreating it with the same values is supported by the Creator. SupportRecreate bool // ChangeEntity is an optional configuration field for tests that involve updating an entity. // This field express what Entity fields are allowed to be changed by the user of the Updater crud interface. // For example, if the changed Entity field is ignored by the Update method, // you can match this by not changing the Entity field as part of the ChangeEntity function. ChangeEntity func(testing.TB, *ENT) // ExampleEntity is an optional field that able to return back an example Entity. // The Entity should have a valid ID and should exist in the resource which is being tested. // // ExampleEntity enables testing a resource that doesn't implement the crud.Creator interface. ExampleEntity func(testing.TB) ENT }
type QueryManyFunc ¶
type QueryOneFunc ¶
type QueryOneFunc[Entity any] func(tb testing.TB, ctx context.Context, ent Entity) (_ Entity, found bool, _ error)
Query takes an entity value and returns with a closure that has the knowledge about how to query resource to find passed entity.
By convention, any preparation action that affect the resource must take place prior to returning the closure. The QueryOneFunc closure should only have the Method call with the already mapped values. Query will be evaluated in the beginning of the testing, and executed after all the test Context preparation is done.
The func signature for Query is the generic representation of a query that meant to find one result. It is really similar to resources.Finder#FindByID, with the exception that the closure meant to know the query method name on the subject and the inputs it requires.
type TestingTBContextKey ¶
type TestingTBContextKey struct{}