crudcontracts

package
v0.147.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 17 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] func(testing.TB) AllDeleterSubject[Entity, ID]

func (AllDeleter[Entity, ID]) Benchmark

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

func (AllDeleter[Entity, ID]) Name added in v0.136.0

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

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] struct {
	Resource    allDeleterSubjectResource[Entity, ID]
	MakeContext func() context.Context
	MakeEntity  func() Entity
}

type AllFinder

type AllFinder[Entity, ID any] func(testing.TB) AllFinderSubject[Entity, ID]

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 (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] struct {
	Resource    allFinderSubjectResource[Entity, ID]
	MakeContext func() context.Context
	MakeEntity  func() Entity
}

type ByIDDeleter

type ByIDDeleter[Entity, ID any] func(testing.TB) ByIDDeleterSubject[Entity, ID]

func (ByIDDeleter[Entity, ID]) Benchmark

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

func (ByIDDeleter[Entity, ID]) Name added in v0.136.0

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

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] struct {
	Resource    spechelper.CRD[Entity, ID]
	MakeContext func() context.Context
	MakeEntity  func() Entity
}

type ByIDFinder

type ByIDFinder[Entity, ID any] func(testing.TB) ByIDFinderSubject[Entity, ID]

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] struct {
	Resource    spechelper.CRD[Entity, ID]
	MakeContext func() context.Context
	MakeEntity  func() Entity
}

type Creator

type Creator[Entity, ID any] func(tb testing.TB) CreatorSubject[Entity, ID]

func (Creator[Entity, ID]) Benchmark

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

func (Creator[Entity, ID]) Name added in v0.136.0

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

func (Creator[Entity, ID]) Spec

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

func (Creator[Entity, ID]) Test

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

type CreatorSubject

type CreatorSubject[Entity, ID any] struct {
	Resource    spechelper.CRD[Entity, ID]
	MakeContext func() context.Context
	MakeEntity  func() 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
}

type Deleter

type Deleter[Entity, ID any] func(testing.TB) DeleterSubject[Entity, ID]

func (Deleter[Entity, ID]) Benchmark

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

func (Deleter[Entity, ID]) Name added in v0.136.0

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

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] struct {
	Resource interface {
		spechelper.CRD[Entity, ID]
		crud.AllDeleter
	}
	MakeContext func() context.Context
	MakeEntity  func() Entity
}

type Finder

type Finder[Entity, ID any] func(testing.TB) FinderSubject[Entity, ID]

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] struct {
	Resource interface {
		spechelper.CRD[Entity, ID]
		crud.AllFinder[Entity]
	}
	MakeContext func() context.Context
	MakeEntity  func() Entity
}

type OnePhaseCommitProtocol

type OnePhaseCommitProtocol[Entity, ID any] func(testing.TB) OnePhaseCommitProtocolSubject[Entity, ID]

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
	MakeContext   func() context.Context
	MakeEntity    func() Entity
}

type Purger

type Purger[Entity, ID any] func(testing.TB) PurgerSubject[Entity, ID]

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] struct {
	Resource    purgerSubjectResource[Entity, ID]
	MakeEntity  func() Entity
	MakeContext func() context.Context
}

type QueryMany

type QueryMany[Entity, ID any] func(testing.TB) QueryManySubject[Entity, ID]

func (QueryMany[Entity, ID]) Benchmark

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

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 QueryManySubject

type QueryManySubject[Entity, ID any] struct {
	// Resource is the resource that can contain entities.
	Resource spechelper.CRD[Entity, ID]
	// Query is the function that knows how to execute a query that will match MakeIncludedEntity.
	//
	// 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.
	Query       func(ctx context.Context) iterators.Iterator[Entity]
	MakeContext func() context.Context
	// MakeIncludedEntity must return an entity that is matched by the QueryManyFunc
	MakeIncludedEntity func() Entity
	// MakeExcludedEntity [OPTIONAL] is an optional property,
	// that could be used ensure the query returns only the expected values.
	MakeExcludedEntity func() Entity
	// Specify allow further specification describing for a given QueryOne query function.
	// If none specified, this field will be ignored
	Specify func(testing.TB)
}

type QueryOne

type QueryOne[Entity, ID any] func(testing.TB) QueryOneSubject[Entity, ID]

func (QueryOne[Entity, ID]) Benchmark

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

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 QueryOneSubject

type QueryOneSubject[Entity, ID any] struct {
	// Resource is the resource that can contain entities.
	Resource spechelper.CRD[Entity, ID]
	// Name is the name of the test subject QueryOneFunc method of this contract specification.
	Name string
	// 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.
	Query       func(ctx context.Context, ent Entity) (_ Entity, found bool, _ error)
	MakeContext func() context.Context
	MakeEntity  func() Entity
	// Specify allow further specification describing for a given QueryOne query function.
	// If none specified, this field will be ignored
	Specify func(testing.TB)
}

type Suite added in v0.136.0

type Suite suites.Suite

func SuiteFor added in v0.136.0

func SuiteFor[
	Entity, ID any,
	Resource suiteSubjectResource[Entity, ID],
](makeSubject func(testing.TB) SuiteSubject[Entity, ID, Resource]) Suite

type SuiteSubject added in v0.136.0

type SuiteSubject[
	Entity, ID any,
	Resource suiteSubjectResource[Entity, ID],
] struct {
	Resource              Resource
	CommitManager         comproto.OnePhaseCommitProtocol
	MakeContext           func() context.Context
	MakeEntity            func() Entity
	CreateSupportIDReuse  bool
	CreateSupportRecreate bool
}

type Updater

type Updater[Entity, ID any] func(testing.TB) UpdaterSubject[Entity, ID]

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]) Name added in v0.136.0

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

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] struct {
	Resource    updaterSubjectResource[Entity, ID]
	MakeContext func() context.Context
	MakeEntity  func() 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(*Entity)
}

Jump to

Keyboard shortcuts

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