mock

package
v2.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheMock

type CacheMock struct {
	// CloseFunc mocks the Close method.
	CloseFunc func(ctx context.Context) error

	// GetPermissionsBundleFunc mocks the GetPermissionsBundle method.
	GetPermissionsBundleFunc func(ctx context.Context) (permissions.Bundle, error)

	// HealthCheckFunc mocks the HealthCheck method.
	HealthCheckFunc func(ctx context.Context, state *healthcheck.CheckState) error
	// contains filtered or unexported fields
}

CacheMock is a mock implementation of permissions.Cache.

    func TestSomethingThatUsesCache(t *testing.T) {

        // make and configure a mocked permissions.Cache
        mockedCache := &CacheMock{
            CloseFunc: func(ctx context.Context) error {
	               panic("mock out the Close method")
            },
            GetPermissionsBundleFunc: func(ctx context.Context) (permissions.Bundle, error) {
	               panic("mock out the GetPermissionsBundle method")
            },
            HealthCheckFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
	               panic("mock out the HealthCheck method")
            },
        }

        // use mockedCache in code that requires permissions.Cache
        // and then make assertions.

    }

func (*CacheMock) Close

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

Close calls CloseFunc.

func (*CacheMock) CloseCalls

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

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

len(mockedCache.CloseCalls())

func (*CacheMock) GetPermissionsBundle

func (mock *CacheMock) GetPermissionsBundle(ctx context.Context) (permissions.Bundle, error)

GetPermissionsBundle calls GetPermissionsBundleFunc.

func (*CacheMock) GetPermissionsBundleCalls

func (mock *CacheMock) GetPermissionsBundleCalls() []struct {
	Ctx context.Context
}

GetPermissionsBundleCalls gets all the calls that were made to GetPermissionsBundle. Check the length with:

len(mockedCache.GetPermissionsBundleCalls())

func (*CacheMock) HealthCheck

func (mock *CacheMock) HealthCheck(ctx context.Context, state *healthcheck.CheckState) error

HealthCheck calls HealthCheckFunc.

func (*CacheMock) HealthCheckCalls

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

HealthCheckCalls gets all the calls that were made to HealthCheck. Check the length with:

len(mockedCache.HealthCheckCalls())

type StoreMock

type StoreMock struct {
	// GetPermissionsBundleFunc mocks the GetPermissionsBundle method.
	GetPermissionsBundleFunc func(ctx context.Context) (permissions.Bundle, error)
	// contains filtered or unexported fields
}

StoreMock is a mock implementation of permissions.Store.

    func TestSomethingThatUsesStore(t *testing.T) {

        // make and configure a mocked permissions.Store
        mockedStore := &StoreMock{
            GetPermissionsBundleFunc: func(ctx context.Context) (permissions.Bundle, error) {
	               panic("mock out the GetPermissionsBundle method")
            },
        }

        // use mockedStore in code that requires permissions.Store
        // and then make assertions.

    }

func (*StoreMock) GetPermissionsBundle

func (mock *StoreMock) GetPermissionsBundle(ctx context.Context) (permissions.Bundle, error)

GetPermissionsBundle calls GetPermissionsBundleFunc.

func (*StoreMock) GetPermissionsBundleCalls

func (mock *StoreMock) GetPermissionsBundleCalls() []struct {
	Ctx context.Context
}

GetPermissionsBundleCalls gets all the calls that were made to GetPermissionsBundle. Check the length with:

len(mockedStore.GetPermissionsBundleCalls())

Jump to

Keyboard shortcuts

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