Documentation
¶
Index ¶
- func AllDeleter[ENT, ID any](subject allDeleterSubjectResource[ENT, ID], opts ...Option[ENT, ID]) contract.Contract
- func AllFinder[ENT, ID any](subject crud.AllFinder[ENT], opts ...Option[ENT, ID]) contract.Contract
- func ByIDDeleter[ENT, ID any](subject crud.ByIDDeleter[ID], opts ...Option[ENT, ID]) contract.Contract
- func ByIDFinder[ENT, ID any](subject crud.ByIDFinder[ENT, ID], opts ...Option[ENT, ID]) contract.Contract
- func ByIDsFinder[ENT, ID any](subject crud.ByIDsFinder[ENT, ID], opts ...Option[ENT, ID]) contract.Contract
- func Creator[ENT, ID any](subject crud.Creator[ENT], opts ...Option[ENT, ID]) contract.Contract
- func Deleter[Entity, ID any](subject deleterSubject[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func Finder[ENT, ID any](subject subjectFinder[ENT, ID], opts ...Option[ENT, ID]) contract.Contract
- func OnePhaseCommitProtocol[ENT, ID any](subject any, manager comproto.OnePhaseCommitProtocol, opts ...Option[ENT, ID]) contract.Contract
- func Purger[Entity, ID any](subject purgerSubjectResource[Entity, ID], opts ...Option[Entity, ID]) contract.Contract
- func QueryMany[ENT, ID any](resource any, methodName string, ...) contract.Contract
- func QueryOne[ENT, ID any](resource any, methodName string, ...) contract.Contract
- func Saver[ENT, ID any](subject crud.Saver[ENT], opts ...Option[ENT, ID]) contract.Contract
- func Updater[ENT, ID any](subject crud.Updater[ENT], opts ...Option[ENT, ID]) contract.Contract
- type Config
- type Contract
- type Option
- type QueryManySubject
- type QueryOneSubject
- type TestingTBContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDeleter ¶
func AllFinder ¶
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(testing.TB) 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 // IDA [optional] is the ID Accessor. // Configure this if you don't use the ext:"id" tag in your entity. // TODO: add support for this accessor in crudtest IDA extid.Accessor[ENT, ID] // LazyNotFoundError will allow QueryMany methods to return crud.ErrNotFound during the iteration, // instead during the method call. // For e.g.: crud.ByIDsFinder[ENT, ID] LazyNotFoundError bool }
func (Config[ENT, ID]) ModifyEntity ¶ added in v0.247.0
type QueryManySubject ¶ added in v0.244.0
type QueryManySubject[ENT any] struct { // Query creates a query that expected to find the ExpectedEntity // // 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. Query func(ctx context.Context) iter.Seq2[ENT, error] // IncludedEntity return an entity that is matched by the QueryManyFunc. // If subject doesn't support Creator, then it should be present in the subject resource. IncludedEntity func() ENT // MakeExcludedEntity is an optional property, // that could be used ensure the query returns only the expected values. // If subject doesn't support Creator, then it should be present in the subject resource. ExcludedEntity func() ENT }
type QueryOneSubject ¶ added in v0.244.0
type QueryOneSubject[ENT any] struct { // Query creates a query that expected to find the ExpectedEntity // // 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. Query func(ctx context.Context) (_ ENT, found bool, _ error) // ExpectedEntity is an entity that is matched by the Query. // If subject doesn't support Creator, then it should be present in the subject resource. ExpectedEntity ENT // MakeExcludedEntity is an optional property, // that could be used ensure the query returns only the expected values. // If subject doesn't support Creator, then it should be present in the subject resource. ExcludedEntity func() ENT }
type TestingTBContextKey ¶
type TestingTBContextKey struct{}
Click to show internal directories.
Click to hide internal directories.