storetest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 7 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 {
	// CheckAllBundleContentsAreApprovedFunc mocks the CheckAllBundleContentsAreApproved method.
	CheckAllBundleContentsAreApprovedFunc func(ctx context.Context, bundleID string) (bool, error)

	// CheckBundleExistsFunc mocks the CheckBundleExists method.
	CheckBundleExistsFunc func(ctx context.Context, bundleID string) (bool, error)

	// CheckContentItemExistsByDatasetEditionVersionFunc mocks the CheckContentItemExistsByDatasetEditionVersion method.
	CheckContentItemExistsByDatasetEditionVersionFunc func(ctx context.Context, datasetID string, editionID string, versionID int) (bool, error)

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

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

	// CreateBundleEventFunc mocks the CreateBundleEvent method.
	CreateBundleEventFunc func(ctx context.Context, event *models.Event) error

	// CreateContentItemFunc mocks the CreateContentItem method.
	CreateContentItemFunc func(ctx context.Context, contentItem *models.ContentItem) error

	// GetBundleFunc mocks the GetBundle method.
	GetBundleFunc func(ctx context.Context, bundleID string) (*models.Bundle, error)

	// ListBundleEventsFunc mocks the ListBundleEvents method.
	ListBundleEventsFunc func(ctx context.Context, offset int, limit int, bundleID string, after *time.Time, before *time.Time) ([]*models.Event, int, error)

	// ListBundlesFunc mocks the ListBundles method.
	ListBundlesFunc func(ctx context.Context, offset int, limit int, filtersMoqParam *filters.BundleFilters) ([]*models.Bundle, int, error)

	// UpdateBundleETagFunc mocks the UpdateBundleETag method.
	UpdateBundleETagFunc func(ctx context.Context, bundleID string, email string) (*models.Bundle, 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{
		CheckAllBundleContentsAreApprovedFunc: func(ctx context.Context, bundleID string) (bool, error) {
			panic("mock out the CheckAllBundleContentsAreApproved method")
		},
		CheckBundleExistsFunc: func(ctx context.Context, bundleID string) (bool, error) {
			panic("mock out the CheckBundleExists method")
		},
		CheckContentItemExistsByDatasetEditionVersionFunc: func(ctx context.Context, datasetID string, editionID string, versionID int) (bool, error) {
			panic("mock out the CheckContentItemExistsByDatasetEditionVersion method")
		},
		CheckerFunc: func(contextMoqParam context.Context, checkState *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		CloseFunc: func(contextMoqParam context.Context) error {
			panic("mock out the Close method")
		},
		CreateBundleEventFunc: func(ctx context.Context, event *models.Event) error {
			panic("mock out the CreateBundleEvent method")
		},
		CreateContentItemFunc: func(ctx context.Context, contentItem *models.ContentItem) error {
			panic("mock out the CreateContentItem method")
		},
		GetBundleFunc: func(ctx context.Context, bundleID string) (*models.Bundle, error) {
			panic("mock out the GetBundle method")
		},
		ListBundleEventsFunc: func(ctx context.Context, offset int, limit int, bundleID string, after *time.Time, before *time.Time) ([]*models.Event, int, error) {
			panic("mock out the ListBundleEvents method")
		},
		ListBundlesFunc: func(ctx context.Context, offset int, limit int, filtersMoqParam *filters.BundleFilters) ([]*models.Bundle, int, error) {
			panic("mock out the ListBundles method")
		},
		UpdateBundleETagFunc: func(ctx context.Context, bundleID string, email string) (*models.Bundle, error) {
			panic("mock out the UpdateBundleETag method")
		},
	}

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

}

func (*MongoDBMock) CheckAllBundleContentsAreApproved added in v1.2.0

func (mock *MongoDBMock) CheckAllBundleContentsAreApproved(ctx context.Context, bundleID string) (bool, error)

CheckAllBundleContentsAreApproved calls CheckAllBundleContentsAreApprovedFunc.

func (*MongoDBMock) CheckAllBundleContentsAreApprovedCalls added in v1.2.0

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

CheckAllBundleContentsAreApprovedCalls gets all the calls that were made to CheckAllBundleContentsAreApproved. Check the length with:

len(mockedMongoDB.CheckAllBundleContentsAreApprovedCalls())

func (*MongoDBMock) CheckBundleExists added in v1.3.0

func (mock *MongoDBMock) CheckBundleExists(ctx context.Context, bundleID string) (bool, error)

CheckBundleExists calls CheckBundleExistsFunc.

func (*MongoDBMock) CheckBundleExistsCalls added in v1.3.0

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

CheckBundleExistsCalls gets all the calls that were made to CheckBundleExists. Check the length with:

len(mockedMongoDB.CheckBundleExistsCalls())

func (*MongoDBMock) CheckContentItemExistsByDatasetEditionVersion added in v1.3.0

func (mock *MongoDBMock) CheckContentItemExistsByDatasetEditionVersion(ctx context.Context, datasetID string, editionID string, versionID int) (bool, error)

CheckContentItemExistsByDatasetEditionVersion calls CheckContentItemExistsByDatasetEditionVersionFunc.

func (*MongoDBMock) CheckContentItemExistsByDatasetEditionVersionCalls added in v1.3.0

func (mock *MongoDBMock) CheckContentItemExistsByDatasetEditionVersionCalls() []struct {
	Ctx       context.Context
	DatasetID string
	EditionID string
	VersionID int
}

CheckContentItemExistsByDatasetEditionVersionCalls gets all the calls that were made to CheckContentItemExistsByDatasetEditionVersion. Check the length with:

len(mockedMongoDB.CheckContentItemExistsByDatasetEditionVersionCalls())

func (*MongoDBMock) Checker

func (mock *MongoDBMock) Checker(contextMoqParam context.Context, checkState *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*MongoDBMock) CheckerCalls

func (mock *MongoDBMock) CheckerCalls() []struct {
	ContextMoqParam context.Context
	CheckState      *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(contextMoqParam context.Context) error

Close calls CloseFunc.

func (*MongoDBMock) CloseCalls

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

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

len(mockedMongoDB.CloseCalls())

func (*MongoDBMock) CreateBundleEvent added in v1.3.0

func (mock *MongoDBMock) CreateBundleEvent(ctx context.Context, event *models.Event) error

CreateBundleEvent calls CreateBundleEventFunc.

func (*MongoDBMock) CreateBundleEventCalls added in v1.3.0

func (mock *MongoDBMock) CreateBundleEventCalls() []struct {
	Ctx   context.Context
	Event *models.Event
}

CreateBundleEventCalls gets all the calls that were made to CreateBundleEvent. Check the length with:

len(mockedMongoDB.CreateBundleEventCalls())

func (*MongoDBMock) CreateContentItem added in v1.3.0

func (mock *MongoDBMock) CreateContentItem(ctx context.Context, contentItem *models.ContentItem) error

CreateContentItem calls CreateContentItemFunc.

func (*MongoDBMock) CreateContentItemCalls added in v1.3.0

func (mock *MongoDBMock) CreateContentItemCalls() []struct {
	Ctx         context.Context
	ContentItem *models.ContentItem
}

CreateContentItemCalls gets all the calls that were made to CreateContentItem. Check the length with:

len(mockedMongoDB.CreateContentItemCalls())

func (*MongoDBMock) GetBundle added in v1.3.0

func (mock *MongoDBMock) GetBundle(ctx context.Context, bundleID string) (*models.Bundle, error)

GetBundle calls GetBundleFunc.

func (*MongoDBMock) GetBundleCalls added in v1.3.0

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

GetBundleCalls gets all the calls that were made to GetBundle. Check the length with:

len(mockedMongoDB.GetBundleCalls())

func (*MongoDBMock) ListBundleEvents added in v1.3.0

func (mock *MongoDBMock) ListBundleEvents(ctx context.Context, offset int, limit int, bundleID string, after *time.Time, before *time.Time) ([]*models.Event, int, error)

ListBundleEvents calls ListBundleEventsFunc.

func (*MongoDBMock) ListBundleEventsCalls added in v1.3.0

func (mock *MongoDBMock) ListBundleEventsCalls() []struct {
	Ctx      context.Context
	Offset   int
	Limit    int
	BundleID string
	After    *time.Time
	Before   *time.Time
}

ListBundleEventsCalls gets all the calls that were made to ListBundleEvents. Check the length with:

len(mockedMongoDB.ListBundleEventsCalls())

func (*MongoDBMock) ListBundles

func (mock *MongoDBMock) ListBundles(ctx context.Context, offset int, limit int, filtersMoqParam *filters.BundleFilters) ([]*models.Bundle, int, error)

ListBundles calls ListBundlesFunc.

func (*MongoDBMock) ListBundlesCalls

func (mock *MongoDBMock) ListBundlesCalls() []struct {
	Ctx             context.Context
	Offset          int
	Limit           int
	FiltersMoqParam *filters.BundleFilters
}

ListBundlesCalls gets all the calls that were made to ListBundles. Check the length with:

len(mockedMongoDB.ListBundlesCalls())

func (*MongoDBMock) UpdateBundleETag added in v1.3.0

func (mock *MongoDBMock) UpdateBundleETag(ctx context.Context, bundleID string, email string) (*models.Bundle, error)

UpdateBundleETag calls UpdateBundleETagFunc.

func (*MongoDBMock) UpdateBundleETagCalls added in v1.3.0

func (mock *MongoDBMock) UpdateBundleETagCalls() []struct {
	Ctx      context.Context
	BundleID string
	Email    string
}

UpdateBundleETagCalls gets all the calls that were made to UpdateBundleETag. Check the length with:

len(mockedMongoDB.UpdateBundleETagCalls())

type StorerMock

type StorerMock struct {
	// CheckAllBundleContentsAreApprovedFunc mocks the CheckAllBundleContentsAreApproved method.
	CheckAllBundleContentsAreApprovedFunc func(ctx context.Context, bundleID string) (bool, error)

	// CheckBundleExistsFunc mocks the CheckBundleExists method.
	CheckBundleExistsFunc func(ctx context.Context, bundleID string) (bool, error)

	// CheckContentItemExistsByDatasetEditionVersionFunc mocks the CheckContentItemExistsByDatasetEditionVersion method.
	CheckContentItemExistsByDatasetEditionVersionFunc func(ctx context.Context, datasetID string, editionID string, versionID int) (bool, error)

	// 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

	// CreateBundleEventFunc mocks the CreateBundleEvent method.
	CreateBundleEventFunc func(ctx context.Context, event *models.Event) error

	// CreateContentItemFunc mocks the CreateContentItem method.
	CreateContentItemFunc func(ctx context.Context, contentItem *models.ContentItem) error

	// GetBundleFunc mocks the GetBundle method.
	GetBundleFunc func(ctx context.Context, bundleID string) (*models.Bundle, error)

	// ListBundleEventsFunc mocks the ListBundleEvents method.
	ListBundleEventsFunc func(ctx context.Context, offset int, limit int, bundleID string, after *time.Time, before *time.Time) ([]*models.Event, int, error)

	// ListBundlesFunc mocks the ListBundles method.
	ListBundlesFunc func(ctx context.Context, offset int, limit int, filtersMoqParam *filters.BundleFilters) ([]*models.Bundle, int, error)

	// UpdateBundleETagFunc mocks the UpdateBundleETag method.
	UpdateBundleETagFunc func(ctx context.Context, bundleID string, email string) (*models.Bundle, 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{
		CheckAllBundleContentsAreApprovedFunc: func(ctx context.Context, bundleID string) (bool, error) {
			panic("mock out the CheckAllBundleContentsAreApproved method")
		},
		CheckBundleExistsFunc: func(ctx context.Context, bundleID string) (bool, error) {
			panic("mock out the CheckBundleExists method")
		},
		CheckContentItemExistsByDatasetEditionVersionFunc: func(ctx context.Context, datasetID string, editionID string, versionID int) (bool, error) {
			panic("mock out the CheckContentItemExistsByDatasetEditionVersion method")
		},
		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")
		},
		CreateBundleEventFunc: func(ctx context.Context, event *models.Event) error {
			panic("mock out the CreateBundleEvent method")
		},
		CreateContentItemFunc: func(ctx context.Context, contentItem *models.ContentItem) error {
			panic("mock out the CreateContentItem method")
		},
		GetBundleFunc: func(ctx context.Context, bundleID string) (*models.Bundle, error) {
			panic("mock out the GetBundle method")
		},
		ListBundleEventsFunc: func(ctx context.Context, offset int, limit int, bundleID string, after *time.Time, before *time.Time) ([]*models.Event, int, error) {
			panic("mock out the ListBundleEvents method")
		},
		ListBundlesFunc: func(ctx context.Context, offset int, limit int, filtersMoqParam *filters.BundleFilters) ([]*models.Bundle, int, error) {
			panic("mock out the ListBundles method")
		},
		UpdateBundleETagFunc: func(ctx context.Context, bundleID string, email string) (*models.Bundle, error) {
			panic("mock out the UpdateBundleETag method")
		},
	}

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

}

func (*StorerMock) CheckAllBundleContentsAreApproved added in v1.2.0

func (mock *StorerMock) CheckAllBundleContentsAreApproved(ctx context.Context, bundleID string) (bool, error)

CheckAllBundleContentsAreApproved calls CheckAllBundleContentsAreApprovedFunc.

func (*StorerMock) CheckAllBundleContentsAreApprovedCalls added in v1.2.0

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

CheckAllBundleContentsAreApprovedCalls gets all the calls that were made to CheckAllBundleContentsAreApproved. Check the length with:

len(mockedStorer.CheckAllBundleContentsAreApprovedCalls())

func (*StorerMock) CheckBundleExists added in v1.3.0

func (mock *StorerMock) CheckBundleExists(ctx context.Context, bundleID string) (bool, error)

CheckBundleExists calls CheckBundleExistsFunc.

func (*StorerMock) CheckBundleExistsCalls added in v1.3.0

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

CheckBundleExistsCalls gets all the calls that were made to CheckBundleExists. Check the length with:

len(mockedStorer.CheckBundleExistsCalls())

func (*StorerMock) CheckContentItemExistsByDatasetEditionVersion added in v1.3.0

func (mock *StorerMock) CheckContentItemExistsByDatasetEditionVersion(ctx context.Context, datasetID string, editionID string, versionID int) (bool, error)

CheckContentItemExistsByDatasetEditionVersion calls CheckContentItemExistsByDatasetEditionVersionFunc.

func (*StorerMock) CheckContentItemExistsByDatasetEditionVersionCalls added in v1.3.0

func (mock *StorerMock) CheckContentItemExistsByDatasetEditionVersionCalls() []struct {
	Ctx       context.Context
	DatasetID string
	EditionID string
	VersionID int
}

CheckContentItemExistsByDatasetEditionVersionCalls gets all the calls that were made to CheckContentItemExistsByDatasetEditionVersion. Check the length with:

len(mockedStorer.CheckContentItemExistsByDatasetEditionVersionCalls())

func (*StorerMock) Checker

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

Checker calls CheckerFunc.

func (*StorerMock) CheckerCalls

func (mock *StorerMock) CheckerCalls() []struct {
	Ctx   context.Context
	State *healthcheck.CheckState
}

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

len(mockedStorer.CheckerCalls())

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) CreateBundleEvent added in v1.3.0

func (mock *StorerMock) CreateBundleEvent(ctx context.Context, event *models.Event) error

CreateBundleEvent calls CreateBundleEventFunc.

func (*StorerMock) CreateBundleEventCalls added in v1.3.0

func (mock *StorerMock) CreateBundleEventCalls() []struct {
	Ctx   context.Context
	Event *models.Event
}

CreateBundleEventCalls gets all the calls that were made to CreateBundleEvent. Check the length with:

len(mockedStorer.CreateBundleEventCalls())

func (*StorerMock) CreateContentItem added in v1.3.0

func (mock *StorerMock) CreateContentItem(ctx context.Context, contentItem *models.ContentItem) error

CreateContentItem calls CreateContentItemFunc.

func (*StorerMock) CreateContentItemCalls added in v1.3.0

func (mock *StorerMock) CreateContentItemCalls() []struct {
	Ctx         context.Context
	ContentItem *models.ContentItem
}

CreateContentItemCalls gets all the calls that were made to CreateContentItem. Check the length with:

len(mockedStorer.CreateContentItemCalls())

func (*StorerMock) GetBundle added in v1.3.0

func (mock *StorerMock) GetBundle(ctx context.Context, bundleID string) (*models.Bundle, error)

GetBundle calls GetBundleFunc.

func (*StorerMock) GetBundleCalls added in v1.3.0

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

GetBundleCalls gets all the calls that were made to GetBundle. Check the length with:

len(mockedStorer.GetBundleCalls())

func (*StorerMock) ListBundleEvents added in v1.3.0

func (mock *StorerMock) ListBundleEvents(ctx context.Context, offset int, limit int, bundleID string, after *time.Time, before *time.Time) ([]*models.Event, int, error)

ListBundleEvents calls ListBundleEventsFunc.

func (*StorerMock) ListBundleEventsCalls added in v1.3.0

func (mock *StorerMock) ListBundleEventsCalls() []struct {
	Ctx      context.Context
	Offset   int
	Limit    int
	BundleID string
	After    *time.Time
	Before   *time.Time
}

ListBundleEventsCalls gets all the calls that were made to ListBundleEvents. Check the length with:

len(mockedStorer.ListBundleEventsCalls())

func (*StorerMock) ListBundles

func (mock *StorerMock) ListBundles(ctx context.Context, offset int, limit int, filtersMoqParam *filters.BundleFilters) ([]*models.Bundle, int, error)

ListBundles calls ListBundlesFunc.

func (*StorerMock) ListBundlesCalls

func (mock *StorerMock) ListBundlesCalls() []struct {
	Ctx             context.Context
	Offset          int
	Limit           int
	FiltersMoqParam *filters.BundleFilters
}

ListBundlesCalls gets all the calls that were made to ListBundles. Check the length with:

len(mockedStorer.ListBundlesCalls())

func (*StorerMock) UpdateBundleETag added in v1.3.0

func (mock *StorerMock) UpdateBundleETag(ctx context.Context, bundleID string, email string) (*models.Bundle, error)

UpdateBundleETag calls UpdateBundleETagFunc.

func (*StorerMock) UpdateBundleETagCalls added in v1.3.0

func (mock *StorerMock) UpdateBundleETagCalls() []struct {
	Ctx      context.Context
	BundleID string
	Email    string
}

UpdateBundleETagCalls gets all the calls that were made to UpdateBundleETag. Check the length with:

len(mockedStorer.UpdateBundleETagCalls())

Jump to

Keyboard shortcuts

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