mock

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandlerMock

type AuthHandlerMock struct {
	// RequireFunc mocks the Require method.
	RequireFunc func(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc
	// contains filtered or unexported fields
}

AuthHandlerMock is a mock implementation of api.AuthHandler.

    func TestSomethingThatUsesAuthHandler(t *testing.T) {

        // make and configure a mocked api.AuthHandler
        mockedAuthHandler := &AuthHandlerMock{
            RequireFunc: func(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc {
	               panic("mock out the Require method")
            },
        }

        // use mockedAuthHandler in code that requires api.AuthHandler
        // and then make assertions.

    }

func (*AuthHandlerMock) Require

func (mock *AuthHandlerMock) Require(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc

Require calls RequireFunc.

func (*AuthHandlerMock) RequireCalls

func (mock *AuthHandlerMock) RequireCalls() []struct {
	Required auth.Permissions
	Handler  http.HandlerFunc
}

RequireCalls gets all the calls that were made to Require. Check the length with:

len(mockedAuthHandler.RequireCalls())

type MongoServerMock

type MongoServerMock struct {
	// AcquireImageLockFunc mocks the AcquireImageLock method.
	AcquireImageLockFunc func(ctx context.Context, id string) (string, error)

	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, state *healthcheck.CheckState) error

	// CloseFunc mocks the Close method.
	CloseFunc func(ctx context.Context) error

	// GetImageFunc mocks the GetImage method.
	GetImageFunc func(ctx context.Context, id string) (*models.Image, error)

	// GetImagesFunc mocks the GetImages method.
	GetImagesFunc func(ctx context.Context, collectionID string) ([]models.Image, error)

	// UnlockImageFunc mocks the UnlockImage method.
	UnlockImageFunc func(ctx context.Context, lockID string)

	// UpdateImageFunc mocks the UpdateImage method.
	UpdateImageFunc func(ctx context.Context, id string, image *models.Image) (bool, error)

	// UpsertImageFunc mocks the UpsertImage method.
	UpsertImageFunc func(ctx context.Context, id string, image *models.Image) error
	// contains filtered or unexported fields
}

MongoServerMock is a mock implementation of api.MongoServer.

    func TestSomethingThatUsesMongoServer(t *testing.T) {

        // make and configure a mocked api.MongoServer
        mockedMongoServer := &MongoServerMock{
            AcquireImageLockFunc: func(ctx context.Context, id string) (string, error) {
	               panic("mock out the AcquireImageLock method")
            },
            CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
	               panic("mock out the Checker method")
            },
            CloseFunc: func(ctx context.Context) error {
	               panic("mock out the Close method")
            },
            GetImageFunc: func(ctx context.Context, id string) (*models.Image, error) {
	               panic("mock out the GetImage method")
            },
            GetImagesFunc: func(ctx context.Context, collectionID string) ([]models.Image, error) {
	               panic("mock out the GetImages method")
            },
            UnlockImageFunc: func(ctx context.Context, lockID string)  {
	               panic("mock out the UnlockImage method")
            },
            UpdateImageFunc: func(ctx context.Context, id string, image *models.Image) (bool, error) {
	               panic("mock out the UpdateImage method")
            },
            UpsertImageFunc: func(ctx context.Context, id string, image *models.Image) error {
	               panic("mock out the UpsertImage method")
            },
        }

        // use mockedMongoServer in code that requires api.MongoServer
        // and then make assertions.

    }

func (*MongoServerMock) AcquireImageLock added in v0.8.0

func (mock *MongoServerMock) AcquireImageLock(ctx context.Context, id string) (string, error)

AcquireImageLock calls AcquireImageLockFunc.

func (*MongoServerMock) AcquireImageLockCalls added in v0.8.0

func (mock *MongoServerMock) AcquireImageLockCalls() []struct {
	Ctx context.Context
	ID  string
}

AcquireImageLockCalls gets all the calls that were made to AcquireImageLock. Check the length with:

len(mockedMongoServer.AcquireImageLockCalls())

func (*MongoServerMock) Checker

func (mock *MongoServerMock) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*MongoServerMock) CheckerCalls

func (mock *MongoServerMock) CheckerCalls() []struct {
	Ctx   context.Context
	State *healthcheck.CheckState
}

CheckerCalls gets all the calls that were made to Checker. Check the length with:

len(mockedMongoServer.CheckerCalls())

func (*MongoServerMock) Close

func (mock *MongoServerMock) Close(ctx context.Context) error

Close calls CloseFunc.

func (*MongoServerMock) CloseCalls

func (mock *MongoServerMock) CloseCalls() []struct {
	Ctx context.Context
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedMongoServer.CloseCalls())

func (*MongoServerMock) GetImage

func (mock *MongoServerMock) GetImage(ctx context.Context, id string) (*models.Image, error)

GetImage calls GetImageFunc.

func (*MongoServerMock) GetImageCalls

func (mock *MongoServerMock) GetImageCalls() []struct {
	Ctx context.Context
	ID  string
}

GetImageCalls gets all the calls that were made to GetImage. Check the length with:

len(mockedMongoServer.GetImageCalls())

func (*MongoServerMock) GetImages

func (mock *MongoServerMock) GetImages(ctx context.Context, collectionID string) ([]models.Image, error)

GetImages calls GetImagesFunc.

func (*MongoServerMock) GetImagesCalls

func (mock *MongoServerMock) GetImagesCalls() []struct {
	Ctx          context.Context
	CollectionID string
}

GetImagesCalls gets all the calls that were made to GetImages. Check the length with:

len(mockedMongoServer.GetImagesCalls())

func (*MongoServerMock) UnlockImage added in v0.8.0

func (mock *MongoServerMock) UnlockImage(ctx context.Context, lockID string)

UnlockImage calls UnlockImageFunc.

func (*MongoServerMock) UnlockImageCalls added in v0.8.0

func (mock *MongoServerMock) UnlockImageCalls() []struct {
	Ctx    context.Context
	LockID string
}

UnlockImageCalls gets all the calls that were made to UnlockImage. Check the length with:

len(mockedMongoServer.UnlockImageCalls())

func (*MongoServerMock) UpdateImage

func (mock *MongoServerMock) UpdateImage(ctx context.Context, id string, image *models.Image) (bool, error)

UpdateImage calls UpdateImageFunc.

func (*MongoServerMock) UpdateImageCalls

func (mock *MongoServerMock) UpdateImageCalls() []struct {
	Ctx   context.Context
	ID    string
	Image *models.Image
}

UpdateImageCalls gets all the calls that were made to UpdateImage. Check the length with:

len(mockedMongoServer.UpdateImageCalls())

func (*MongoServerMock) UpsertImage

func (mock *MongoServerMock) UpsertImage(ctx context.Context, id string, image *models.Image) error

UpsertImage calls UpsertImageFunc.

func (*MongoServerMock) UpsertImageCalls

func (mock *MongoServerMock) UpsertImageCalls() []struct {
	Ctx   context.Context
	ID    string
	Image *models.Image
}

UpsertImageCalls gets all the calls that were made to UpsertImage. Check the length with:

len(mockedMongoServer.UpsertImageCalls())

Jump to

Keyboard shortcuts

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