storetest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBMock

type MongoDBMock struct {
	// 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

	// GetTopicFunc mocks the GetTopic method.
	GetTopicFunc func(id string) (*models.TopicResponse, error)
	// contains filtered or unexported fields
}

MongoDBMock is a mock implementation of store.MongoDB.

    func TestSomethingThatUsesMongoServer(t *testing.T) {

        // make and configure a mocked store.MongoDB
        mockedMongoServer := &MongoDBMock{
            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")
            },
            GetTopicFunc: func(id string) (*models.TopicResponse, error) {
	               panic("mock out the GetTopic method")
            },
        }

        // use mockedMongoServer in code that requires store.MongoDB
        // and then make assertions.

    }

func (*MongoDBMock) Checker

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

Checker calls CheckerFunc.

func (*MongoDBMock) CheckerCalls

func (mock *MongoDBMock) 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 (*MongoDBMock) Close

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

Close calls CloseFunc.

func (*MongoDBMock) CloseCalls

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

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

len(mockedMongoServer.CloseCalls())

func (*MongoDBMock) GetTopic

func (mock *MongoDBMock) GetTopic(id string) (*models.TopicResponse, error)

GetTopic calls GetTopicFunc.

func (*MongoDBMock) GetTopicCalls

func (mock *MongoDBMock) GetTopicCalls() []struct {
	ID string
}

GetTopicCalls gets all the calls that were made to GetTopic. Check the length with:

len(mockedMongoServer.GetTopicCalls())

type StorerMock

type StorerMock struct {
	// GetTopicFunc mocks the GetTopic method.
	GetTopicFunc func(ID string) (*models.TopicResponse, error)
	// contains filtered or unexported fields
}

func (*StorerMock) GetTopic

func (mock *StorerMock) GetTopic(ID string) (*models.TopicResponse, error)

GetTopic calls GetTopicFunc.

func (*StorerMock) GetTopicCalls

func (mock *StorerMock) GetTopicCalls() []struct {
	ID string
}

GetTopicCalls gets all the calls that were made to GetTopic. Check the length with:

len(mockedStorer.GetTopicCalls())

Jump to

Keyboard shortcuts

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