mock

package
v2.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 5 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) (permsdk.Bundle, error)

	// HealthCheckFunc mocks the HealthCheck method.
	HealthCheckFunc func(ctx context.Context, state *health.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) (permsdk.Bundle, error) {
			panic("mock out the GetPermissionsBundle method")
		},
		HealthCheckFunc: func(ctx context.Context, state *health.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) (permsdk.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 *health.CheckState) error

HealthCheck calls HealthCheckFunc.

func (*CacheMock) HealthCheckCalls

func (mock *CacheMock) HealthCheckCalls() []struct {
	Ctx   context.Context
	State *health.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) (permsdk.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) (permsdk.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) (permsdk.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