store

package
v0.0.0-...-600007b Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderByNamespace = OrderingField("entity.namespace")
	OrderByName      = OrderingField("entity.name")
)

Variables

This section is empty.

Functions

func NewSqliteStore

func NewSqliteStore(connString string) (*sqliteStore, error)

Types

type Filter

type Filter struct {
	Key   string
	Value string
}

type Ordering

type Ordering struct {
	OrderBy    OrderingField
	Descending bool
}

type OrderingField

type OrderingField string

type Pagination

type Pagination struct {
	Limit  int
	Offset int
}

type Store

type Store interface {
	CreateComponent(c model.Component) (model.Component, error)
	ReadComponent(ref model.EntityRef) (model.Component, error)
	UpdateComponent(c model.Component) (model.Component, error)
	DeleteComponent(ref model.EntityRef) (model.Component, error)
	ListComponents(filters []Filter, ordering Ordering, pagination Pagination) ([]model.EntityRef, Pagination, error)

	CreateAPI(a model.API) (model.API, error)
	ReadAPI(ref model.EntityRef) (model.API, error)
	UpdateAPI(a model.API) (model.API, error)
	DeleteAPI(ref model.EntityRef) (model.API, error)

	CreateUser(u model.User) (model.User, error)
	ReadUser(ref model.EntityRef) (model.User, error)
	UpdateUser(u model.User) (model.User, error)
	DeleteUser(ref model.EntityRef) (model.User, error)

	CreateGroup(g model.Group) (model.Group, error)
	ReadGroup(ref model.EntityRef) (model.Group, error)
	UpdateGroup(g model.Group) (model.Group, error)
	DeleteGroup(ref model.EntityRef) (model.Group, error)
}

type StoreMock

type StoreMock struct {
	// CreateAPIFunc mocks the CreateAPI method.
	CreateAPIFunc func(a model.API) (model.API, error)

	// CreateComponentFunc mocks the CreateComponent method.
	CreateComponentFunc func(c model.Component) (model.Component, error)

	// CreateGroupFunc mocks the CreateGroup method.
	CreateGroupFunc func(g model.Group) (model.Group, error)

	// CreateUserFunc mocks the CreateUser method.
	CreateUserFunc func(u model.User) (model.User, error)

	// DeleteAPIFunc mocks the DeleteAPI method.
	DeleteAPIFunc func(ref model.EntityRef) (model.API, error)

	// DeleteComponentFunc mocks the DeleteComponent method.
	DeleteComponentFunc func(ref model.EntityRef) (model.Component, error)

	// DeleteGroupFunc mocks the DeleteGroup method.
	DeleteGroupFunc func(ref model.EntityRef) (model.Group, error)

	// DeleteUserFunc mocks the DeleteUser method.
	DeleteUserFunc func(ref model.EntityRef) (model.User, error)

	// ListComponentsFunc mocks the ListComponents method.
	ListComponentsFunc func(filters []Filter, ordering Ordering, pagination Pagination) ([]model.EntityRef, Pagination, error)

	// ReadAPIFunc mocks the ReadAPI method.
	ReadAPIFunc func(ref model.EntityRef) (model.API, error)

	// ReadComponentFunc mocks the ReadComponent method.
	ReadComponentFunc func(ref model.EntityRef) (model.Component, error)

	// ReadGroupFunc mocks the ReadGroup method.
	ReadGroupFunc func(ref model.EntityRef) (model.Group, error)

	// ReadUserFunc mocks the ReadUser method.
	ReadUserFunc func(ref model.EntityRef) (model.User, error)

	// UpdateAPIFunc mocks the UpdateAPI method.
	UpdateAPIFunc func(a model.API) (model.API, error)

	// UpdateComponentFunc mocks the UpdateComponent method.
	UpdateComponentFunc func(c model.Component) (model.Component, error)

	// UpdateGroupFunc mocks the UpdateGroup method.
	UpdateGroupFunc func(g model.Group) (model.Group, error)

	// UpdateUserFunc mocks the UpdateUser method.
	UpdateUserFunc func(u model.User) (model.User, error)
	// contains filtered or unexported fields
}

StoreMock is a mock implementation of Store.

func TestSomethingThatUsesStore(t *testing.T) {

	// make and configure a mocked Store
	mockedStore := &StoreMock{
		CreateAPIFunc: func(a model.API) (model.API, error) {
			panic("mock out the CreateAPI method")
		},
		CreateComponentFunc: func(c model.Component) (model.Component, error) {
			panic("mock out the CreateComponent method")
		},
		CreateGroupFunc: func(g model.Group) (model.Group, error) {
			panic("mock out the CreateGroup method")
		},
		CreateUserFunc: func(u model.User) (model.User, error) {
			panic("mock out the CreateUser method")
		},
		DeleteAPIFunc: func(ref model.EntityRef) (model.API, error) {
			panic("mock out the DeleteAPI method")
		},
		DeleteComponentFunc: func(ref model.EntityRef) (model.Component, error) {
			panic("mock out the DeleteComponent method")
		},
		DeleteGroupFunc: func(ref model.EntityRef) (model.Group, error) {
			panic("mock out the DeleteGroup method")
		},
		DeleteUserFunc: func(ref model.EntityRef) (model.User, error) {
			panic("mock out the DeleteUser method")
		},
		ListComponentsFunc: func(filters []Filter, ordering Ordering, pagination Pagination) ([]model.EntityRef, Pagination, error) {
			panic("mock out the ListComponents method")
		},
		ReadAPIFunc: func(ref model.EntityRef) (model.API, error) {
			panic("mock out the ReadAPI method")
		},
		ReadComponentFunc: func(ref model.EntityRef) (model.Component, error) {
			panic("mock out the ReadComponent method")
		},
		ReadGroupFunc: func(ref model.EntityRef) (model.Group, error) {
			panic("mock out the ReadGroup method")
		},
		ReadUserFunc: func(ref model.EntityRef) (model.User, error) {
			panic("mock out the ReadUser method")
		},
		UpdateAPIFunc: func(a model.API) (model.API, error) {
			panic("mock out the UpdateAPI method")
		},
		UpdateComponentFunc: func(c model.Component) (model.Component, error) {
			panic("mock out the UpdateComponent method")
		},
		UpdateGroupFunc: func(g model.Group) (model.Group, error) {
			panic("mock out the UpdateGroup method")
		},
		UpdateUserFunc: func(u model.User) (model.User, error) {
			panic("mock out the UpdateUser method")
		},
	}

	// use mockedStore in code that requires Store
	// and then make assertions.

}

func (*StoreMock) CreateAPI

func (mock *StoreMock) CreateAPI(a model.API) (model.API, error)

CreateAPI calls CreateAPIFunc.

func (*StoreMock) CreateAPICalls

func (mock *StoreMock) CreateAPICalls() []struct {
	A model.API
}

CreateAPICalls gets all the calls that were made to CreateAPI. Check the length with:

len(mockedStore.CreateAPICalls())

func (*StoreMock) CreateComponent

func (mock *StoreMock) CreateComponent(c model.Component) (model.Component, error)

CreateComponent calls CreateComponentFunc.

func (*StoreMock) CreateComponentCalls

func (mock *StoreMock) CreateComponentCalls() []struct {
	C model.Component
}

CreateComponentCalls gets all the calls that were made to CreateComponent. Check the length with:

len(mockedStore.CreateComponentCalls())

func (*StoreMock) CreateGroup

func (mock *StoreMock) CreateGroup(g model.Group) (model.Group, error)

CreateGroup calls CreateGroupFunc.

func (*StoreMock) CreateGroupCalls

func (mock *StoreMock) CreateGroupCalls() []struct {
	G model.Group
}

CreateGroupCalls gets all the calls that were made to CreateGroup. Check the length with:

len(mockedStore.CreateGroupCalls())

func (*StoreMock) CreateUser

func (mock *StoreMock) CreateUser(u model.User) (model.User, error)

CreateUser calls CreateUserFunc.

func (*StoreMock) CreateUserCalls

func (mock *StoreMock) CreateUserCalls() []struct {
	U model.User
}

CreateUserCalls gets all the calls that were made to CreateUser. Check the length with:

len(mockedStore.CreateUserCalls())

func (*StoreMock) DeleteAPI

func (mock *StoreMock) DeleteAPI(ref model.EntityRef) (model.API, error)

DeleteAPI calls DeleteAPIFunc.

func (*StoreMock) DeleteAPICalls

func (mock *StoreMock) DeleteAPICalls() []struct {
	Ref model.EntityRef
}

DeleteAPICalls gets all the calls that were made to DeleteAPI. Check the length with:

len(mockedStore.DeleteAPICalls())

func (*StoreMock) DeleteComponent

func (mock *StoreMock) DeleteComponent(ref model.EntityRef) (model.Component, error)

DeleteComponent calls DeleteComponentFunc.

func (*StoreMock) DeleteComponentCalls

func (mock *StoreMock) DeleteComponentCalls() []struct {
	Ref model.EntityRef
}

DeleteComponentCalls gets all the calls that were made to DeleteComponent. Check the length with:

len(mockedStore.DeleteComponentCalls())

func (*StoreMock) DeleteGroup

func (mock *StoreMock) DeleteGroup(ref model.EntityRef) (model.Group, error)

DeleteGroup calls DeleteGroupFunc.

func (*StoreMock) DeleteGroupCalls

func (mock *StoreMock) DeleteGroupCalls() []struct {
	Ref model.EntityRef
}

DeleteGroupCalls gets all the calls that were made to DeleteGroup. Check the length with:

len(mockedStore.DeleteGroupCalls())

func (*StoreMock) DeleteUser

func (mock *StoreMock) DeleteUser(ref model.EntityRef) (model.User, error)

DeleteUser calls DeleteUserFunc.

func (*StoreMock) DeleteUserCalls

func (mock *StoreMock) DeleteUserCalls() []struct {
	Ref model.EntityRef
}

DeleteUserCalls gets all the calls that were made to DeleteUser. Check the length with:

len(mockedStore.DeleteUserCalls())

func (*StoreMock) ListComponents

func (mock *StoreMock) ListComponents(filters []Filter, ordering Ordering, pagination Pagination) ([]model.EntityRef, Pagination, error)

ListComponents calls ListComponentsFunc.

func (*StoreMock) ListComponentsCalls

func (mock *StoreMock) ListComponentsCalls() []struct {
	Filters    []Filter
	Ordering   Ordering
	Pagination Pagination
}

ListComponentsCalls gets all the calls that were made to ListComponents. Check the length with:

len(mockedStore.ListComponentsCalls())

func (*StoreMock) ReadAPI

func (mock *StoreMock) ReadAPI(ref model.EntityRef) (model.API, error)

ReadAPI calls ReadAPIFunc.

func (*StoreMock) ReadAPICalls

func (mock *StoreMock) ReadAPICalls() []struct {
	Ref model.EntityRef
}

ReadAPICalls gets all the calls that were made to ReadAPI. Check the length with:

len(mockedStore.ReadAPICalls())

func (*StoreMock) ReadComponent

func (mock *StoreMock) ReadComponent(ref model.EntityRef) (model.Component, error)

ReadComponent calls ReadComponentFunc.

func (*StoreMock) ReadComponentCalls

func (mock *StoreMock) ReadComponentCalls() []struct {
	Ref model.EntityRef
}

ReadComponentCalls gets all the calls that were made to ReadComponent. Check the length with:

len(mockedStore.ReadComponentCalls())

func (*StoreMock) ReadGroup

func (mock *StoreMock) ReadGroup(ref model.EntityRef) (model.Group, error)

ReadGroup calls ReadGroupFunc.

func (*StoreMock) ReadGroupCalls

func (mock *StoreMock) ReadGroupCalls() []struct {
	Ref model.EntityRef
}

ReadGroupCalls gets all the calls that were made to ReadGroup. Check the length with:

len(mockedStore.ReadGroupCalls())

func (*StoreMock) ReadUser

func (mock *StoreMock) ReadUser(ref model.EntityRef) (model.User, error)

ReadUser calls ReadUserFunc.

func (*StoreMock) ReadUserCalls

func (mock *StoreMock) ReadUserCalls() []struct {
	Ref model.EntityRef
}

ReadUserCalls gets all the calls that were made to ReadUser. Check the length with:

len(mockedStore.ReadUserCalls())

func (*StoreMock) UpdateAPI

func (mock *StoreMock) UpdateAPI(a model.API) (model.API, error)

UpdateAPI calls UpdateAPIFunc.

func (*StoreMock) UpdateAPICalls

func (mock *StoreMock) UpdateAPICalls() []struct {
	A model.API
}

UpdateAPICalls gets all the calls that were made to UpdateAPI. Check the length with:

len(mockedStore.UpdateAPICalls())

func (*StoreMock) UpdateComponent

func (mock *StoreMock) UpdateComponent(c model.Component) (model.Component, error)

UpdateComponent calls UpdateComponentFunc.

func (*StoreMock) UpdateComponentCalls

func (mock *StoreMock) UpdateComponentCalls() []struct {
	C model.Component
}

UpdateComponentCalls gets all the calls that were made to UpdateComponent. Check the length with:

len(mockedStore.UpdateComponentCalls())

func (*StoreMock) UpdateGroup

func (mock *StoreMock) UpdateGroup(g model.Group) (model.Group, error)

UpdateGroup calls UpdateGroupFunc.

func (*StoreMock) UpdateGroupCalls

func (mock *StoreMock) UpdateGroupCalls() []struct {
	G model.Group
}

UpdateGroupCalls gets all the calls that were made to UpdateGroup. Check the length with:

len(mockedStore.UpdateGroupCalls())

func (*StoreMock) UpdateUser

func (mock *StoreMock) UpdateUser(u model.User) (model.User, error)

UpdateUser calls UpdateUserFunc.

func (*StoreMock) UpdateUserCalls

func (mock *StoreMock) UpdateUserCalls() []struct {
	U model.User
}

UpdateUserCalls gets all the calls that were made to UpdateUser. Check the length with:

len(mockedStore.UpdateUserCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳