datastoretest

package
v0.3.654 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAllTests

func RunAllTests(t *testing.T, dsf DataStoreFunc, rp ResourceProvider)

func RunAppsTest

func RunAppsTest(t *testing.T, dsf DataStoreFunc, rp ResourceProvider)

func RunFnsTest

func RunFnsTest(t *testing.T, dsf DataStoreFunc, rp ResourceProvider)

func RunTriggerBySourceTests

func RunTriggerBySourceTests(t *testing.T, dsf DataStoreFunc, rp ResourceProvider)

func RunTriggersTest

func RunTriggersTest(t *testing.T, dsf DataStoreFunc, rp ResourceProvider)

Types

type AppByName

type AppByName []*models.App

func (AppByName) Len

func (a AppByName) Len() int

func (AppByName) Less

func (a AppByName) Less(i, j int) bool

func (AppByName) Swap

func (a AppByName) Swap(i, j int)

type BasicResourceProvider

type BasicResourceProvider struct {
	// contains filtered or unexported fields
}

BasicResourceProvider supplies simple objects and can be used as a base for custom resource providers

func (*BasicResourceProvider) DefaultCtx

func (brp *BasicResourceProvider) DefaultCtx() context.Context

func (*BasicResourceProvider) NextID

func (brp *BasicResourceProvider) NextID() uint32

func (*BasicResourceProvider) ValidApp

func (brp *BasicResourceProvider) ValidApp() *models.App

Creates a valid app which always has a sequential named

func (*BasicResourceProvider) ValidFn

func (brp *BasicResourceProvider) ValidFn(appId string) *models.Fn

func (*BasicResourceProvider) ValidTrigger

func (brp *BasicResourceProvider) ValidTrigger(appId, funcId string) *models.Trigger

type DataStoreFunc

type DataStoreFunc func(*testing.T) models.Datastore

DataStoreFunc provides an instance of a data store

type FnByName

type FnByName []*models.Fn

func (FnByName) Len

func (f FnByName) Len() int

func (FnByName) Less

func (f FnByName) Less(i, j int) bool

func (FnByName) Swap

func (f FnByName) Swap(i, j int)

type Harness

type Harness struct {
	// contains filtered or unexported fields
}

func NewHarness

func NewHarness(t *testing.T, ctx context.Context, ds models.Datastore) *Harness

func (*Harness) AppForDeletion

func (h *Harness) AppForDeletion(app *models.App)

func (*Harness) Cleanup

func (h *Harness) Cleanup()

func (*Harness) GivenAppInDb

func (h *Harness) GivenAppInDb(app *models.App) *models.App

func (*Harness) GivenFnInDb

func (h *Harness) GivenFnInDb(validFunc *models.Fn) *models.Fn

func (*Harness) GivenTriggerInDb

func (h *Harness) GivenTriggerInDb(validTrigger *models.Trigger) *models.Trigger

type ResourceProvider

type ResourceProvider interface {
	// ValidApp returns a valid app to use for inserts
	ValidApp() *models.App
	// ValidFn returns a valid fn to use for inserts
	ValidFn(appId string) *models.Fn
	// ValidTrigger returns a valid trigger  to use for inserts
	ValidTrigger(appId string, fnId string) *models.Trigger

	// DefaultCtx returns a context object (which may have custom attributes set)
	// this may be used (e.g.) to pass on tenancy and user details that would originate from a middleware to your data store
	DefaultCtx() context.Context
}

ResourceProvider provides an abstraction for supplying data store tests with appropriate initial testing objects for running tests Use the resource calls to supply objects with (e.g.) middleware enforced annotations set on them Use DefaultCtx to override custom middleware-supplied context variables

func NewBasicResourceProvider

func NewBasicResourceProvider() ResourceProvider

NewBasicResourceProvider creates a dumb resource provider that generates resources that have valid, random names (and other unique attributes)

type TriggerByName

type TriggerByName []*models.Trigger

func (TriggerByName) Len

func (f TriggerByName) Len() int

func (TriggerByName) Less

func (f TriggerByName) Less(i, j int) bool

func (TriggerByName) Swap

func (f TriggerByName) Swap(i, j int)

Jump to

Keyboard shortcuts

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