crudcontracts

package
v0.110.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllDeleter

type AllDeleter[Entity, ID any] struct {
	MakeSubject func(testing.TB) AllDeleterSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (AllDeleter[Entity, ID]) Benchmark

func (c AllDeleter[Entity, ID]) Benchmark(b *testing.B)

func (AllDeleter[Entity, ID]) Spec

func (c AllDeleter[Entity, ID]) Spec(s *testcase.Spec)

func (AllDeleter[Entity, ID]) Test

func (c AllDeleter[Entity, ID]) Test(t *testing.T)

type AllDeleterSubject

type AllDeleterSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.AllDeleter
}

type AllFinder

type AllFinder[Entity, ID any] struct {
	MakeSubject func(testing.TB) AllFinderSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

AllFinder can return business entities from a given resource that implement it's test The "EntityTypeName" is a 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 (AllFinder[Entity, ID]) Benchmark

func (c AllFinder[Entity, ID]) Benchmark(b *testing.B)

func (AllFinder[Entity, ID]) Name

func (c AllFinder[Entity, ID]) Name() string

func (AllFinder[Entity, ID]) Spec

func (c AllFinder[Entity, ID]) Spec(s *testcase.Spec)

func (AllFinder[Entity, ID]) Test

func (c AllFinder[Entity, ID]) Test(t *testing.T)

type AllFinderSubject

type AllFinderSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.AllFinder[Entity]
}

type ByIDDeleter

type ByIDDeleter[Entity, ID any] struct {
	MakeSubject func(testing.TB) ByIDDeleterSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (ByIDDeleter[Entity, ID]) Benchmark

func (c ByIDDeleter[Entity, ID]) Benchmark(b *testing.B)

func (ByIDDeleter[Entity, ID]) Spec

func (c ByIDDeleter[Entity, ID]) Spec(s *testcase.Spec)

func (ByIDDeleter[Entity, ID]) Test

func (c ByIDDeleter[Entity, ID]) Test(t *testing.T)

type ByIDDeleterSubject

type ByIDDeleterSubject[Entity, ID any] spechelper.CRD[Entity, ID]

type ByIDFinder

type ByIDFinder[Entity, ID any] struct {
	MakeSubject func(testing.TB) ByIDFinderSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (ByIDFinder[Entity, ID]) Benchmark

func (c ByIDFinder[Entity, ID]) Benchmark(b *testing.B)

func (ByIDFinder[Entity, ID]) Name

func (c ByIDFinder[Entity, ID]) Name() string

func (ByIDFinder[Entity, ID]) Spec

func (c ByIDFinder[Entity, ID]) Spec(s *testcase.Spec)

func (ByIDFinder[Entity, ID]) Test

func (c ByIDFinder[Entity, ID]) Test(t *testing.T)

type ByIDFinderSubject

type ByIDFinderSubject[Entity, ID any] spechelper.CRD[Entity, ID]

type Creator

type Creator[Entity, ID any] struct {
	MakeSubject func(testing.TB) CreatorSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
	// 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
}

func (Creator[Entity, ID]) Benchmark

func (c Creator[Entity, ID]) Benchmark(b *testing.B)

func (Creator[Entity, ID]) Spec

func (c Creator[Entity, ID]) Spec(s *testcase.Spec)

func (Creator[T, ID]) Test

func (c Creator[T, ID]) Test(t *testing.T)

type CreatorSubject

type CreatorSubject[Entity, ID any] spechelper.CRD[Entity, ID]

type Deleter

type Deleter[Entity, ID any] struct {
	MakeSubject func(testing.TB) DeleterSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (Deleter[Entity, ID]) Benchmark

func (c Deleter[Entity, ID]) Benchmark(b *testing.B)

func (Deleter[Entity, ID]) Spec

func (c Deleter[Entity, ID]) Spec(s *testcase.Spec)

func (Deleter[Entity, ID]) Test

func (c Deleter[Entity, ID]) Test(t *testing.T)

type DeleterSubject

type DeleterSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.AllDeleter
}

type Finder

type Finder[Entity, ID any] struct {
	MakeSubject func(testing.TB) FinderSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (Finder[Entity, ID]) Benchmark

func (c Finder[Entity, ID]) Benchmark(b *testing.B)

func (Finder[Entity, ID]) Spec

func (c Finder[Entity, ID]) Spec(s *testcase.Spec)

func (Finder[Entity, ID]) Test

func (c Finder[Entity, ID]) Test(t *testing.T)

type FinderSubject

type FinderSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.AllFinder[Entity]
}

type OnePhaseCommitProtocol

type OnePhaseCommitProtocol[Entity, ID any] struct {
	MakeSubject func(testing.TB) OnePhaseCommitProtocolSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (OnePhaseCommitProtocol[Entity, ID]) Benchmark

func (c OnePhaseCommitProtocol[Entity, ID]) Benchmark(b *testing.B)

func (OnePhaseCommitProtocol[Entity, ID]) Name

func (c OnePhaseCommitProtocol[Entity, ID]) Name() string

func (OnePhaseCommitProtocol[Entity, ID]) Spec

func (c OnePhaseCommitProtocol[Entity, ID]) Spec(s *testcase.Spec)

func (OnePhaseCommitProtocol[Entity, ID]) Test

func (c OnePhaseCommitProtocol[Entity, ID]) Test(t *testing.T)

type OnePhaseCommitProtocolSubject

type OnePhaseCommitProtocolSubject[Entity, ID any] struct {
	Resource      spechelper.CRD[Entity, ID]
	CommitManager comproto.OnePhaseCommitProtocol
}

type Purger

type Purger[Entity, ID any] struct {
	MakeSubject func(testing.TB) PurgerSubject[Entity, ID]
	MakeEntity  func(testing.TB) Entity
	MakeContext func(testing.TB) context.Context
}

func (Purger[Entity, ID]) Benchmark

func (c Purger[Entity, ID]) Benchmark(b *testing.B)

func (Purger[Entity, ID]) Spec

func (c Purger[Entity, ID]) Spec(s *testcase.Spec)

func (Purger[Entity, ID]) Test

func (c Purger[Entity, ID]) Test(t *testing.T)

type PurgerSubject

type PurgerSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.Purger
}

type QueryMany

type QueryMany[Entity, ID any] struct {
	MakeSubject func(testing.TB) QueryManySubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	// QueryName is the name of the test subject QueryOneFunc method of this contract specification.
	QueryName string
	// MakeIncludedEntity must return an entity that is matched by the QueryManyFunc
	MakeIncludedEntity func(testing.TB) Entity
	// MakeExcludedEntity [OPTIONAL] is an optional property,
	// that could be used ensure the query returns only the expected values.
	MakeExcludedEntity func(testing.TB) Entity
	// Specify allow further specification describing for a given QueryOne query function.
	// If none specified, this field will be ignored
	Specify func(testing.TB)
}

func (QueryMany[Entity, ID]) Benchmark

func (c QueryMany[Entity, ID]) Benchmark(b *testing.B)

func (QueryMany[Entity, ID]) Name

func (c QueryMany[Entity, ID]) Name() string

func (QueryMany[Entity, ID]) Spec

func (c QueryMany[Entity, ID]) Spec(s *testcase.Spec)

func (QueryMany[Entity, ID]) Test

func (c QueryMany[Entity, ID]) Test(t *testing.T)

type QueryManyFunc

type QueryManyFunc[Entity any] func(tb testing.TB, ctx context.Context) iterators.Iterator[Entity]

QueryManyFunc is the generic representation of a query that meant to find many result. It is really similar to resources.Finder#FindAll, with the exception that the closure meant to know the query method name on the subject and the inputs it requires.

QueryOneFunc is generated through ToQuery factory function in QueryOne resource contract specification.

type QueryManySubject

type QueryManySubject[Entity, ID any] struct {
	// Resource is the resource that can contain entities.
	Resource spechelper.CRD[Entity, ID]
	// MakeQuery is the function that knows how to build up the QueryManyFunc.
	MakeQuery QueryManyFunc[Entity]
}

type QueryOne

type QueryOne[Entity, ID any] struct {
	MakeSubject func(testing.TB) QueryOneSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
	// QueryName is the name of the test subject QueryOneFunc method of this contract specification.
	QueryName string
	// Specify allow further specification describing for a given QueryOne query function.
	// If none specified, this field will be ignored
	Specify func(testing.TB)
}

func (QueryOne[Entity, ID]) Benchmark

func (c QueryOne[Entity, ID]) Benchmark(b *testing.B)

func (QueryOne[Entity, ID]) Name

func (c QueryOne[Entity, ID]) Name() string

func (QueryOne[Entity, ID]) Spec

func (c QueryOne[Entity, ID]) Spec(s *testcase.Spec)

func (QueryOne[Entity, ID]) Test

func (c QueryOne[Entity, ID]) Test(t *testing.T)

type QueryOneFunc

type QueryOneFunc[Entity any] func(tb testing.TB, ctx context.Context, ent Entity) (_ Entity, found bool, _ error)

QueryOneFunc 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.

QueryOneFunc is generated through ToQuery factory function in QueryOne resource contract specification.

type QueryOneSubject

type QueryOneSubject[Entity, ID any] struct {
	// Resource is the resource that can contain entities.
	Resource spechelper.CRD[Entity, ID]
	// Query takes an entity ptr and returns with a closure that has the knowledge about how to query on the MakeSubject resource to find the 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.
	Query QueryOneFunc[Entity]
}

type Updater

type Updater[Entity, ID any] struct {
	MakeSubject func(testing.TB) UpdaterSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity

	// ChangeEntity is an optional configuration field
	// to express what Entity fields are allowed to be changed by the user of the Updater.
	// 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, *Entity)
}

Updater will request an update for a wrapped entity object in the Resource

func (Updater[Entity, ID]) Benchmark

func (c Updater[Entity, ID]) Benchmark(b *testing.B)

func (Updater[Entity, ID]) Spec

func (c Updater[Entity, ID]) Spec(s *testcase.Spec)

func (Updater[Entity, ID]) Test

func (c Updater[Entity, ID]) Test(t *testing.T)

type UpdaterSubject

type UpdaterSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.Updater[Entity]
}

Jump to

Keyboard shortcuts

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