datastoretest

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 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 StorerMock

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

	// GetHierarchyCodelistFunc mocks the GetHierarchyCodelist method.
	GetHierarchyCodelistFunc func(ctx context.Context, instanceID string, dimension string) (string, error)

	// GetHierarchyElementFunc mocks the GetHierarchyElement method.
	GetHierarchyElementFunc func(ctx context.Context, instanceID string, dimension string, code string) (*models.HierarchyResponse, error)

	// GetHierarchyRootFunc mocks the GetHierarchyRoot method.
	GetHierarchyRootFunc func(ctx context.Context, instanceID string, dimension string) (*models.HierarchyResponse, error)
	// contains filtered or unexported fields
}

StorerMock is a mock implementation of datastore.Storer.

    func TestSomethingThatUsesStorer(t *testing.T) {

        // make and configure a mocked datastore.Storer
        mockedStorer := &StorerMock{
            CloseFunc: func(ctx context.Context) error {
	               panic("mock out the Close method")
            },
            GetHierarchyCodelistFunc: func(ctx context.Context, instanceID string, dimension string) (string, error) {
	               panic("mock out the GetHierarchyCodelist method")
            },
            GetHierarchyElementFunc: func(ctx context.Context, instanceID string, dimension string, code string) (*models.HierarchyResponse, error) {
	               panic("mock out the GetHierarchyElement method")
            },
            GetHierarchyRootFunc: func(ctx context.Context, instanceID string, dimension string) (*models.HierarchyResponse, error) {
	               panic("mock out the GetHierarchyRoot method")
            },
        }

        // use mockedStorer in code that requires datastore.Storer
        // and then make assertions.

    }

func (*StorerMock) Close

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

Close calls CloseFunc.

func (*StorerMock) CloseCalls

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

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

len(mockedStorer.CloseCalls())

func (*StorerMock) GetHierarchyCodelist

func (mock *StorerMock) GetHierarchyCodelist(ctx context.Context, instanceID string, dimension string) (string, error)

GetHierarchyCodelist calls GetHierarchyCodelistFunc.

func (*StorerMock) GetHierarchyCodelistCalls

func (mock *StorerMock) GetHierarchyCodelistCalls() []struct {
	Ctx        context.Context
	InstanceID string
	Dimension  string
}

GetHierarchyCodelistCalls gets all the calls that were made to GetHierarchyCodelist. Check the length with:

len(mockedStorer.GetHierarchyCodelistCalls())

func (*StorerMock) GetHierarchyElement

func (mock *StorerMock) GetHierarchyElement(ctx context.Context, instanceID string, dimension string, code string) (*models.HierarchyResponse, error)

GetHierarchyElement calls GetHierarchyElementFunc.

func (*StorerMock) GetHierarchyElementCalls

func (mock *StorerMock) GetHierarchyElementCalls() []struct {
	Ctx        context.Context
	InstanceID string
	Dimension  string
	Code       string
}

GetHierarchyElementCalls gets all the calls that were made to GetHierarchyElement. Check the length with:

len(mockedStorer.GetHierarchyElementCalls())

func (*StorerMock) GetHierarchyRoot

func (mock *StorerMock) GetHierarchyRoot(ctx context.Context, instanceID string, dimension string) (*models.HierarchyResponse, error)

GetHierarchyRoot calls GetHierarchyRootFunc.

func (*StorerMock) GetHierarchyRootCalls

func (mock *StorerMock) GetHierarchyRootCalls() []struct {
	Ctx        context.Context
	InstanceID string
	Dimension  string
}

GetHierarchyRootCalls gets all the calls that were made to GetHierarchyRoot. Check the length with:

len(mockedStorer.GetHierarchyRootCalls())

Jump to

Keyboard shortcuts

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