mock

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBMock

type MongoDBMock struct {
	// CheckTopicExistsFunc mocks the CheckTopicExists method.
	CheckTopicExistsFunc func(ctx context.Context, id string) error

	// CheckerFunc mocks the Checker method.
	CheckerFunc func(in1 context.Context, in2 *healthcheck.CheckState) error

	// CloseFunc mocks the Close method.
	CloseFunc func(in1 context.Context) error

	// GetContentFunc mocks the GetContent method.
	GetContentFunc func(ctx context.Context, id string, queryTypeFlags int) (*models.ContentResponse, error)

	// GetTopicFunc mocks the GetTopic method.
	GetTopicFunc func(ctx context.Context, id string) (*models.TopicResponse, error)

	// UpdateReleaseDateFunc mocks the UpdateReleaseDate method.
	UpdateReleaseDateFunc func(ctx context.Context, id string, releaseDate time.Time) error

	// UpdateStateFunc mocks the UpdateState method.
	UpdateStateFunc func(ctx context.Context, id string, state string) error

	// UpdateTopicFunc mocks the UpdateTopic method.
	UpdateTopicFunc func(ctx context.Context, host string, id string, topic *models.TopicUpdate) error

	// UpsertTopicFunc mocks the UpsertTopic method.
	UpsertTopicFunc func(ctx context.Context, id string, topic *models.TopicResponse) error
	// contains filtered or unexported fields
}

MongoDBMock is a mock implementation of store.MongoDB.

    func TestSomethingThatUsesMongoDB(t *testing.T) {

        // make and configure a mocked store.MongoDB
        mockedMongoDB := &MongoDBMock{
            CheckTopicExistsFunc: func(ctx context.Context, id string) error {
	               panic("mock out the CheckTopicExists method")
            },
            CheckerFunc: func(in1 context.Context, in2 *healthcheck.CheckState) error {
	               panic("mock out the Checker method")
            },
            CloseFunc: func(in1 context.Context) error {
	               panic("mock out the Close method")
            },
            GetContentFunc: func(ctx context.Context, id string, queryTypeFlags int) (*models.ContentResponse, error) {
	               panic("mock out the GetContent method")
            },
            GetTopicFunc: func(ctx context.Context, id string) (*models.TopicResponse, error) {
	               panic("mock out the GetTopic method")
            },
            UpdateReleaseDateFunc: func(ctx context.Context, id string, releaseDate time.Time) error {
	               panic("mock out the UpdateReleaseDate method")
            },
            UpdateStateFunc: func(ctx context.Context, id string, state string) error {
	               panic("mock out the UpdateState method")
            },
            UpdateTopicFunc: func(ctx context.Context, host string, id string, topic *models.TopicUpdate) error {
	               panic("mock out the UpdateTopic method")
            },
            UpsertTopicFunc: func(ctx context.Context, id string, topic *models.TopicResponse) error {
	               panic("mock out the UpsertTopic method")
            },
        }

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

    }

func (*MongoDBMock) CheckTopicExists

func (mock *MongoDBMock) CheckTopicExists(ctx context.Context, id string) error

CheckTopicExists calls CheckTopicExistsFunc.

func (*MongoDBMock) CheckTopicExistsCalls

func (mock *MongoDBMock) CheckTopicExistsCalls() []struct {
	Ctx context.Context
	ID  string
}

CheckTopicExistsCalls gets all the calls that were made to CheckTopicExists. Check the length with:

len(mockedMongoDB.CheckTopicExistsCalls())

func (*MongoDBMock) Checker

func (mock *MongoDBMock) Checker(in1 context.Context, in2 *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*MongoDBMock) CheckerCalls

func (mock *MongoDBMock) CheckerCalls() []struct {
	In1 context.Context
	In2 *healthcheck.CheckState
}

CheckerCalls gets all the calls that were made to Checker. Check the length with:

len(mockedMongoDB.CheckerCalls())

func (*MongoDBMock) Close

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

Close calls CloseFunc.

func (*MongoDBMock) CloseCalls

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

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

len(mockedMongoDB.CloseCalls())

func (*MongoDBMock) GetContent

func (mock *MongoDBMock) GetContent(ctx context.Context, id string, queryTypeFlags int) (*models.ContentResponse, error)

GetContent calls GetContentFunc.

func (*MongoDBMock) GetContentCalls

func (mock *MongoDBMock) GetContentCalls() []struct {
	Ctx            context.Context
	ID             string
	QueryTypeFlags int
}

GetContentCalls gets all the calls that were made to GetContent. Check the length with:

len(mockedMongoDB.GetContentCalls())

func (*MongoDBMock) GetTopic

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

GetTopic calls GetTopicFunc.

func (*MongoDBMock) GetTopicCalls

func (mock *MongoDBMock) GetTopicCalls() []struct {
	Ctx context.Context
	ID  string
}

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

len(mockedMongoDB.GetTopicCalls())

func (*MongoDBMock) UpdateReleaseDate

func (mock *MongoDBMock) UpdateReleaseDate(ctx context.Context, id string, releaseDate time.Time) error

UpdateReleaseDate calls UpdateReleaseDateFunc.

func (*MongoDBMock) UpdateReleaseDateCalls

func (mock *MongoDBMock) UpdateReleaseDateCalls() []struct {
	Ctx         context.Context
	ID          string
	ReleaseDate time.Time
}

UpdateReleaseDateCalls gets all the calls that were made to UpdateReleaseDate. Check the length with:

len(mockedMongoDB.UpdateReleaseDateCalls())

func (*MongoDBMock) UpdateState

func (mock *MongoDBMock) UpdateState(ctx context.Context, id string, state string) error

UpdateState calls UpdateStateFunc.

func (*MongoDBMock) UpdateStateCalls

func (mock *MongoDBMock) UpdateStateCalls() []struct {
	Ctx   context.Context
	ID    string
	State string
}

UpdateStateCalls gets all the calls that were made to UpdateState. Check the length with:

len(mockedMongoDB.UpdateStateCalls())

func (*MongoDBMock) UpdateTopic

func (mock *MongoDBMock) UpdateTopic(ctx context.Context, host string, id string, topic *models.TopicUpdate) error

UpdateTopic calls UpdateTopicFunc.

func (*MongoDBMock) UpdateTopicCalls

func (mock *MongoDBMock) UpdateTopicCalls() []struct {
	Ctx   context.Context
	Host  string
	ID    string
	Topic *models.TopicUpdate
}

UpdateTopicCalls gets all the calls that were made to UpdateTopic. Check the length with:

len(mockedMongoDB.UpdateTopicCalls())

func (*MongoDBMock) UpsertTopic added in v0.17.0

func (mock *MongoDBMock) UpsertTopic(ctx context.Context, id string, topic *models.TopicResponse) error

UpsertTopic calls UpsertTopicFunc.

func (*MongoDBMock) UpsertTopicCalls added in v0.17.0

func (mock *MongoDBMock) UpsertTopicCalls() []struct {
	Ctx   context.Context
	ID    string
	Topic *models.TopicResponse
}

UpsertTopicCalls gets all the calls that were made to UpsertTopic. Check the length with:

len(mockedMongoDB.UpsertTopicCalls())

type StorerMock

type StorerMock struct {
	// CheckTopicExistsFunc mocks the CheckTopicExists method.
	CheckTopicExistsFunc func(ctx context.Context, id string) error

	// GetContentFunc mocks the GetContent method.
	GetContentFunc func(ctx context.Context, id string, queryTypeFlags int) (*models.ContentResponse, error)

	// GetTopicFunc mocks the GetTopic method.
	GetTopicFunc func(ctx context.Context, id string) (*models.TopicResponse, error)

	// UpdateReleaseDateFunc mocks the UpdateReleaseDate method.
	UpdateReleaseDateFunc func(ctx context.Context, id string, releaseDate time.Time) error

	// UpdateStateFunc mocks the UpdateState method.
	UpdateStateFunc func(ctx context.Context, id string, state string) error

	// UpdateTopicFunc mocks the UpdateTopic method.
	UpdateTopicFunc func(ctx context.Context, host string, id string, topic *models.TopicUpdate) error

	// UpsertTopicFunc mocks the UpsertTopic method.
	UpsertTopicFunc func(ctx context.Context, id string, topic *models.TopicResponse) error
	// contains filtered or unexported fields
}

StorerMock is a mock implementation of store.Storer.

    func TestSomethingThatUsesStorer(t *testing.T) {

        // make and configure a mocked store.Storer
        mockedStorer := &StorerMock{
            CheckTopicExistsFunc: func(ctx context.Context, id string) error {
	               panic("mock out the CheckTopicExists method")
            },
            GetContentFunc: func(ctx context.Context, id string, queryTypeFlags int) (*models.ContentResponse, error) {
	               panic("mock out the GetContent method")
            },
            GetTopicFunc: func(ctx context.Context, id string) (*models.TopicResponse, error) {
	               panic("mock out the GetTopic method")
            },
            UpdateReleaseDateFunc: func(ctx context.Context, id string, releaseDate time.Time) error {
	               panic("mock out the UpdateReleaseDate method")
            },
            UpdateStateFunc: func(ctx context.Context, id string, state string) error {
	               panic("mock out the UpdateState method")
            },
            UpdateTopicFunc: func(ctx context.Context, host string, id string, topic *models.TopicUpdate) error {
	               panic("mock out the UpdateTopic method")
            },
            UpsertTopicFunc: func(ctx context.Context, id string, topic *models.TopicResponse) error {
	               panic("mock out the UpsertTopic method")
            },
        }

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

    }

func (*StorerMock) CheckTopicExists

func (mock *StorerMock) CheckTopicExists(ctx context.Context, id string) error

CheckTopicExists calls CheckTopicExistsFunc.

func (*StorerMock) CheckTopicExistsCalls

func (mock *StorerMock) CheckTopicExistsCalls() []struct {
	Ctx context.Context
	ID  string
}

CheckTopicExistsCalls gets all the calls that were made to CheckTopicExists. Check the length with:

len(mockedStorer.CheckTopicExistsCalls())

func (*StorerMock) GetContent

func (mock *StorerMock) GetContent(ctx context.Context, id string, queryTypeFlags int) (*models.ContentResponse, error)

GetContent calls GetContentFunc.

func (*StorerMock) GetContentCalls

func (mock *StorerMock) GetContentCalls() []struct {
	Ctx            context.Context
	ID             string
	QueryTypeFlags int
}

GetContentCalls gets all the calls that were made to GetContent. Check the length with:

len(mockedStorer.GetContentCalls())

func (*StorerMock) GetTopic

func (mock *StorerMock) GetTopic(ctx context.Context, id string) (*models.TopicResponse, error)

GetTopic calls GetTopicFunc.

func (*StorerMock) GetTopicCalls

func (mock *StorerMock) GetTopicCalls() []struct {
	Ctx context.Context
	ID  string
}

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

len(mockedStorer.GetTopicCalls())

func (*StorerMock) UpdateReleaseDate

func (mock *StorerMock) UpdateReleaseDate(ctx context.Context, id string, releaseDate time.Time) error

UpdateReleaseDate calls UpdateReleaseDateFunc.

func (*StorerMock) UpdateReleaseDateCalls

func (mock *StorerMock) UpdateReleaseDateCalls() []struct {
	Ctx         context.Context
	ID          string
	ReleaseDate time.Time
}

UpdateReleaseDateCalls gets all the calls that were made to UpdateReleaseDate. Check the length with:

len(mockedStorer.UpdateReleaseDateCalls())

func (*StorerMock) UpdateState

func (mock *StorerMock) UpdateState(ctx context.Context, id string, state string) error

UpdateState calls UpdateStateFunc.

func (*StorerMock) UpdateStateCalls

func (mock *StorerMock) UpdateStateCalls() []struct {
	Ctx   context.Context
	ID    string
	State string
}

UpdateStateCalls gets all the calls that were made to UpdateState. Check the length with:

len(mockedStorer.UpdateStateCalls())

func (*StorerMock) UpdateTopic

func (mock *StorerMock) UpdateTopic(ctx context.Context, host string, id string, topic *models.TopicUpdate) error

UpdateTopic calls UpdateTopicFunc.

func (*StorerMock) UpdateTopicCalls

func (mock *StorerMock) UpdateTopicCalls() []struct {
	Ctx   context.Context
	Host  string
	ID    string
	Topic *models.TopicUpdate
}

UpdateTopicCalls gets all the calls that were made to UpdateTopic. Check the length with:

len(mockedStorer.UpdateTopicCalls())

func (*StorerMock) UpsertTopic added in v0.17.0

func (mock *StorerMock) UpsertTopic(ctx context.Context, id string, topic *models.TopicResponse) error

UpsertTopic calls UpsertTopicFunc.

func (*StorerMock) UpsertTopicCalls added in v0.17.0

func (mock *StorerMock) UpsertTopicCalls() []struct {
	Ctx   context.Context
	ID    string
	Topic *models.TopicResponse
}

UpsertTopicCalls gets all the calls that were made to UpsertTopic. Check the length with:

len(mockedStorer.UpsertTopicCalls())

Jump to

Keyboard shortcuts

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