crudcontracts

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 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 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] spechelper.CRD[Ent, ID]

type FindOne

type FindOne[Ent, ID any] struct {
	Subject func(testing.TB) FinderSubject[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 Storage 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 FinderSubject[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]) Spec

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

func (FindOne[Ent, ID]) String

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

func (FindOne[Ent, ID]) Test

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

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] spechelper.CRD[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
}

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