mocks

package
v0.0.0-...-a21f649 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package mocks requires the github.com/matryer/moq lib to be installed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ThingReaderWriterMock

type ThingReaderWriterMock struct {
	// CreateFunc mocks the Create method.
	CreateFunc func(ctx context.Context, args backbone.ThingCreate) (*backbone.Thing, error)

	// DeleteFunc mocks the Delete method.
	DeleteFunc func(ctx context.Context, args backbone.ThingArgs) error

	// ThingFunc mocks the Thing method.
	ThingFunc func(ctx context.Context, args backbone.ThingArgs) (*backbone.Thing, error)

	// ThingsFunc mocks the Things method.
	ThingsFunc func(ctx context.Context) ([]*backbone.Thing, error)

	// UpdateFunc mocks the Update method.
	UpdateFunc func(ctx context.Context, args backbone.ThingArgs, req backbone.ThingUpdate) (*backbone.Thing, error)
	// contains filtered or unexported fields
}

ThingReaderWriterMock is a mock implementation of ThingReaderWriter.

    func TestSomethingThatUsesThingReaderWriter(t *testing.T) {

        // make and configure a mocked ThingReaderWriter
        mockedThingReaderWriter := &ThingReaderWriterMock{
            CreateFunc: func(ctx context.Context, args backbone.ThingCreate) (*backbone.Thing, error) {
	               panic("mock out the Create method")
            },
            DeleteFunc: func(ctx context.Context, args backbone.ThingArgs) error {
	               panic("mock out the Delete method")
            },
            ThingFunc: func(ctx context.Context, args backbone.ThingArgs) (*backbone.Thing, error) {
	               panic("mock out the Thing method")
            },
            ThingsFunc: func(ctx context.Context) ([]*backbone.Thing, error) {
	               panic("mock out the Things method")
            },
            UpdateFunc: func(ctx context.Context, args backbone.ThingArgs, req backbone.ThingUpdate) (*backbone.Thing, error) {
	               panic("mock out the Update method")
            },
        }

        // use mockedThingReaderWriter in code that requires ThingReaderWriter
        // and then make assertions.

    }

func (*ThingReaderWriterMock) Create

Create calls CreateFunc.

func (*ThingReaderWriterMock) CreateCalls

func (mock *ThingReaderWriterMock) CreateCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingCreate
}

CreateCalls gets all the calls that were made to Create. Check the length with:

len(mockedThingReaderWriter.CreateCalls())

func (*ThingReaderWriterMock) Delete

func (mock *ThingReaderWriterMock) Delete(ctx context.Context, args backbone.ThingArgs) error

Delete calls DeleteFunc.

func (*ThingReaderWriterMock) DeleteCalls

func (mock *ThingReaderWriterMock) DeleteCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingArgs
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedThingReaderWriter.DeleteCalls())

func (*ThingReaderWriterMock) Thing

Thing calls ThingFunc.

func (*ThingReaderWriterMock) ThingCalls

func (mock *ThingReaderWriterMock) ThingCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingArgs
}

ThingCalls gets all the calls that were made to Thing. Check the length with:

len(mockedThingReaderWriter.ThingCalls())

func (*ThingReaderWriterMock) Things

func (mock *ThingReaderWriterMock) Things(ctx context.Context) ([]*backbone.Thing, error)

Things calls ThingsFunc.

func (*ThingReaderWriterMock) ThingsCalls

func (mock *ThingReaderWriterMock) ThingsCalls() []struct {
	Ctx context.Context
}

ThingsCalls gets all the calls that were made to Things. Check the length with:

len(mockedThingReaderWriter.ThingsCalls())

func (*ThingReaderWriterMock) Update

Update calls UpdateFunc.

func (*ThingReaderWriterMock) UpdateCalls

func (mock *ThingReaderWriterMock) UpdateCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingArgs
	Req  backbone.ThingUpdate
}

UpdateCalls gets all the calls that were made to Update. Check the length with:

len(mockedThingReaderWriter.UpdateCalls())

type ThingServiceMock

type ThingServiceMock struct {
	// CreateFunc mocks the Create method.
	CreateFunc func(ctx context.Context, req backbone.ThingCreate) (*backbone.Thing, error)

	// DeleteFunc mocks the Delete method.
	DeleteFunc func(ctx context.Context, args backbone.ThingArgs) error

	// ThingFunc mocks the Thing method.
	ThingFunc func(ctx context.Context, args backbone.ThingArgs) (*backbone.Thing, error)

	// ThingsFunc mocks the Things method.
	ThingsFunc func(ctx context.Context) ([]*backbone.Thing, error)

	// UpdateFunc mocks the Update method.
	UpdateFunc func(ctx context.Context, args backbone.ThingArgs, req backbone.ThingUpdate) (*backbone.Thing, error)
	// contains filtered or unexported fields
}

ThingServiceMock is a mock implementation of ThingService.

    func TestSomethingThatUsesThingService(t *testing.T) {

        // make and configure a mocked ThingService
        mockedThingService := &ThingServiceMock{
            CreateFunc: func(ctx context.Context, req backbone.ThingCreate) (*backbone.Thing, error) {
	               panic("mock out the Create method")
            },
            DeleteFunc: func(ctx context.Context, args backbone.ThingArgs) error {
	               panic("mock out the Delete method")
            },
            ThingFunc: func(ctx context.Context, args backbone.ThingArgs) (*backbone.Thing, error) {
	               panic("mock out the Thing method")
            },
            ThingsFunc: func(ctx context.Context) ([]*backbone.Thing, error) {
	               panic("mock out the Things method")
            },
            UpdateFunc: func(ctx context.Context, args backbone.ThingArgs, req backbone.ThingUpdate) (*backbone.Thing, error) {
	               panic("mock out the Update method")
            },
        }

        // use mockedThingService in code that requires ThingService
        // and then make assertions.

    }

func (*ThingServiceMock) Create

Create calls CreateFunc.

func (*ThingServiceMock) CreateCalls

func (mock *ThingServiceMock) CreateCalls() []struct {
	Ctx context.Context
	Req backbone.ThingCreate
}

CreateCalls gets all the calls that were made to Create. Check the length with:

len(mockedThingService.CreateCalls())

func (*ThingServiceMock) Delete

func (mock *ThingServiceMock) Delete(ctx context.Context, args backbone.ThingArgs) error

Delete calls DeleteFunc.

func (*ThingServiceMock) DeleteCalls

func (mock *ThingServiceMock) DeleteCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingArgs
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedThingService.DeleteCalls())

func (*ThingServiceMock) Thing

Thing calls ThingFunc.

func (*ThingServiceMock) ThingCalls

func (mock *ThingServiceMock) ThingCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingArgs
}

ThingCalls gets all the calls that were made to Thing. Check the length with:

len(mockedThingService.ThingCalls())

func (*ThingServiceMock) Things

func (mock *ThingServiceMock) Things(ctx context.Context) ([]*backbone.Thing, error)

Things calls ThingsFunc.

func (*ThingServiceMock) ThingsCalls

func (mock *ThingServiceMock) ThingsCalls() []struct {
	Ctx context.Context
}

ThingsCalls gets all the calls that were made to Things. Check the length with:

len(mockedThingService.ThingsCalls())

func (*ThingServiceMock) Update

Update calls UpdateFunc.

func (*ThingServiceMock) UpdateCalls

func (mock *ThingServiceMock) UpdateCalls() []struct {
	Ctx  context.Context
	Args backbone.ThingArgs
	Req  backbone.ThingUpdate
}

UpdateCalls gets all the calls that were made to Update. Check the length with:

len(mockedThingService.UpdateCalls())

Jump to

Keyboard shortcuts

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