crudcontracts

package
v0.84.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllDeleter added in v0.84.0

type AllDeleter[Ent, ID any] struct {
	Subject func(testing.TB) AllDeleterSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (AllDeleter[Ent, ID]) Benchmark added in v0.84.0

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

func (AllDeleter[Ent, ID]) Spec added in v0.84.0

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

func (AllDeleter[Ent, ID]) Test added in v0.84.0

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

type AllDeleterSubject added in v0.84.0

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

type AllFinder added in v0.84.0

type AllFinder[Ent, ID any] struct {
	Subject func(testing.TB) AllFinderSubject[Ent, ID]
	Context func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

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[Ent, ID]) Benchmark added in v0.84.0

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

func (AllFinder[Ent, ID]) Name added in v0.84.0

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

func (AllFinder[Ent, ID]) Spec added in v0.84.0

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

func (AllFinder[Ent, ID]) Test added in v0.84.0

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

type AllFinderSubject added in v0.84.0

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

type ByIDDeleter added in v0.84.0

type ByIDDeleter[Ent, ID any] struct {
	Subject func(testing.TB) ByIDDeleterSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (ByIDDeleter[Ent, ID]) Benchmark added in v0.84.0

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

func (ByIDDeleter[Ent, ID]) Spec added in v0.84.0

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

func (ByIDDeleter[Ent, ID]) Test added in v0.84.0

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

type ByIDDeleterSubject added in v0.84.0

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

type ByIDFinder added in v0.84.0

type ByIDFinder[Ent, ID any] struct {
	Subject func(testing.TB) ByIDFinderSubject[Ent, ID]
	Context func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (ByIDFinder[Ent, ID]) Benchmark added in v0.84.0

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

func (ByIDFinder[Ent, ID]) Name added in v0.84.0

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

func (ByIDFinder[Ent, ID]) Spec added in v0.84.0

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

func (ByIDFinder[Ent, ID]) Test added in v0.84.0

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

type ByIDFinderSubject added in v0.84.0

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

type Creator

type Creator[Ent any, ID any] struct {
	Subject func(testing.TB) CreatorSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (Creator[Ent, ID]) Benchmark

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

func (Creator[Ent, ID]) Spec

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

func (Creator[T, ID]) Test

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

type CreatorSubject

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

type Deleter

type Deleter[Ent, ID any] struct {
	Subject func(testing.TB) DeleterSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (Deleter[Ent, ID]) Benchmark

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

func (Deleter[Ent, ID]) Spec

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

func (Deleter[Ent, ID]) Test

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

type DeleterSubject

type DeleterSubject[Ent, ID any] interface {
	AllDeleterSubject[Ent, ID]
	ByIDDeleterSubject[Ent, ID]
}

type FindOne

type FindOne[Ent, ID any] struct {
	Subject func(testing.TB) FindOneSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
	// MethodName is the name of the test subject QueryOne method of this contract specification.
	MethodName string
	// ToQuery takes an entity ptr and returns with a closure that has the knowledge about how to query on the Subject resource to find the entity.
	//
	// By convention, any preparation action that affect the resource must take place prior to returning the closure.
	// The QueryOne closure should only have the Method call with the already mapped values.
	// ToQuery will be evaluated in the beginning of the testing,
	// and executed after all the test Context preparation is done.
	ToQuery func(tb testing.TB, resource FindOneSubject[Ent, ID], ent Ent) QueryOne[Ent]
	// Specify allow further specification describing for a given FindOne query function.
	// If none specified, this field will be ignored
	Specify func(testing.TB)
}

func (FindOne[Ent, ID]) Benchmark

func (c FindOne[Ent, ID]) Benchmark(b *testing.B)

func (FindOne[Ent, ID]) Name added in v0.84.0

func (c FindOne[Ent, ID]) Name() string

func (FindOne[Ent, ID]) Spec

func (c FindOne[Ent, ID]) Spec(s *testcase.Spec)

func (FindOne[Ent, ID]) Test

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

type FindOneSubject added in v0.84.0

type FindOneSubject[Ent, ID any] spechelper.CRD[Ent, ID]

type Finder

type Finder[Ent, ID any] struct {
	Subject func(testing.TB) FinderSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (Finder[Ent, ID]) Benchmark

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

func (Finder[Ent, ID]) Spec

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

func (Finder[Ent, ID]) Test

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

type FinderSubject

type FinderSubject[Ent, ID any] interface {
	ByIDFinderSubject[Ent, ID]
	AllFinderSubject[Ent, ID]
}

type OnePhaseCommitProtocol added in v0.72.0

type OnePhaseCommitProtocol[Ent, ID any] struct {
	Subject func(testing.TB) OnePhaseCommitProtocolSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
}

func (OnePhaseCommitProtocol[Ent, ID]) Benchmark added in v0.72.0

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

func (OnePhaseCommitProtocol[Ent, ID]) Spec added in v0.72.0

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

func (OnePhaseCommitProtocol[Ent, ID]) Test added in v0.72.0

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

type OnePhaseCommitProtocolSubject added in v0.72.0

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

type Purger

type Purger[Ent, ID any] struct {
	Subject func(testing.TB) PurgerSubject[Ent, ID]
	MakeEnt func(testing.TB) Ent
	MakeCtx func(testing.TB) context.Context
}

func (Purger[Ent, ID]) Benchmark

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

func (Purger[Ent, ID]) Spec

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

func (Purger[Ent, ID]) Test

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

type PurgerSubject

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

type QueryOne

type QueryOne[Ent any] func(tb testing.TB, ctx context.Context) (ent Ent, found bool, err error)

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

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

type Updater

type Updater[Ent any, ID any] struct {
	Subject func(testing.TB) UpdaterSubject[Ent, ID]
	MakeCtx func(testing.TB) context.Context
	MakeEnt func(testing.TB) Ent
	// ChangeEnt is an optional option that allows fine control over
	// what will be changed on an Entity during the test of Update method.
	ChangeEnt func(testing.TB, *Ent)
}

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

func (Updater[Ent, ID]) Benchmark

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

func (Updater[Ent, ID]) Spec

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

func (Updater[Ent, ID]) Test

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

type UpdaterSubject

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

Jump to

Keyboard shortcuts

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