manipulate: go.aporeto.io/manipulate/maniptest Index | Files

package maniptest

import "go.aporeto.io/manipulate/maniptest"

Package maniptest contains a Mockable TransactionalManipulator. It implements all method of the TransactionalManipulator but do nothing.

Methods can be mocked by using one of the MockXX method.

For example:

m := maniptest.NewTestManipulator()
m.MockCreate(t, func(context *manipulate.Context, objects ...elemental.Identifiable) error {
    return elemental.NewError("title", "description", "subject", 43)
})

The next calls to the Create method will use the given method, in the context of the given *testing.T. If you need to reset the mocked method in the context of the same test, simply do:

m.MockCreate(t, nil)

Index

Package Files

doc.go manipulator.go subscriber.go tokenmanager.go

type TestManipulator Uses

type TestManipulator interface {
    manipulate.TransactionalManipulator
    MockRetrieveMany(t *testing.T, impl func(mctx manipulate.Context, dest elemental.Identifiables) error)
    MockRetrieve(t *testing.T, impl func(mctx manipulate.Context, object elemental.Identifiable) error)
    MockCreate(t *testing.T, impl func(mctx manipulate.Context, object elemental.Identifiable) error)
    MockUpdate(t *testing.T, impl func(mctx manipulate.Context, object elemental.Identifiable) error)
    MockDelete(t *testing.T, impl func(mctx manipulate.Context, object elemental.Identifiable) error)
    MockDeleteMany(t *testing.T, impl func(mctx manipulate.Context, identity elemental.Identity) error)
    MockCount(t *testing.T, impl func(mctx manipulate.Context, identity elemental.Identity) (int, error))
    MockCommit(t *testing.T, impl func(tid manipulate.TransactionID) error)
    MockAbort(t *testing.T, impl func(tid manipulate.TransactionID) bool)
}

A TestManipulator is the interface of mockable test manipulator.

func NewTestManipulator Uses

func NewTestManipulator() TestManipulator

NewTestManipulator returns a new TestManipulator.

type TestSubscriber Uses

type TestSubscriber interface {
    manipulate.Subscriber
    MockStart(t *testing.T, impl func(context.Context, *elemental.PushFilter))
    MockUpdateFilter(t *testing.T, impl func(*elemental.PushFilter))
    MockEvents(t *testing.T, impl func() chan *elemental.Event)
    MockErrors(t *testing.T, impl func() chan error)
    MockStatus(t *testing.T, impl func() chan manipulate.SubscriberStatus)
}

A TestSubscriber is the interface of mockable test manipulator.

func NewTestSubscriber Uses

func NewTestSubscriber() TestSubscriber

NewTestSubscriber returns a new TestSubscriber.

type TestTokenManager Uses

type TestTokenManager interface {
    manipulate.TokenManager
    MockIssue(t *testing.T, impl func(context.Context) (string, error))
    MockRun(t *testing.T, impl func(ctx context.Context, tokenCh chan string))
}

A TestTokenManager is the interface of mockable test manipulator.

func NewTestTokenManager Uses

func NewTestTokenManager() TestTokenManager

NewTestTokenManager returns a new TestTokenManager.

Package maniptest imports 5 packages (graph). Updated 2019-11-13. Refresh now. Tools for package owners.