storage

package
v0.0.0-...-9a08fb1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func LoadConfiguration

func LoadConfiguration(ctx context.Context) Config

func NewConfig

func NewConfig(host, port, dbname, user, password, sslmode string) Config

func (Config) ConnStr

func (c Config) ConnStr() string

type StorageMock

type StorageMock struct {
	// QueryFunc mocks the Query method.
	QueryFunc func(ctx context.Context, q messagecollector.QueryParams, tenants []string) messagecollector.QueryResult

	// QueryDeviceFunc mocks the QueryDevice method.
	QueryDeviceFunc func(ctx context.Context, deviceID string, tenants []string) messagecollector.QueryResult

	// QueryObjectFunc mocks the QueryObject method.
	QueryObjectFunc func(ctx context.Context, deviceID string, urn string, tenants []string) messagecollector.QueryResult

	// SaveFunc mocks the Save method.
	SaveFunc func(ctx context.Context, m messagecollector.Measurement) error

	// SaveManyFunc mocks the SaveMany method.
	SaveManyFunc func(ctx context.Context, m []messagecollector.Measurement) error
	// contains filtered or unexported fields
}

StorageMock is a mock implementation of Storage.

func TestSomethingThatUsesStorage(t *testing.T) {

	// make and configure a mocked Storage
	mockedStorage := &StorageMock{
		QueryFunc: func(ctx context.Context, q messagecollector.QueryParams, tenants []string) messagecollector.QueryResult {
			panic("mock out the Query method")
		},
		QueryDeviceFunc: func(ctx context.Context, deviceID string, tenants []string) messagecollector.QueryResult {
			panic("mock out the QueryDevice method")
		},
		QueryObjectFunc: func(ctx context.Context, deviceID string, urn string, tenants []string) messagecollector.QueryResult {
			panic("mock out the QueryObject method")
		},
		SaveFunc: func(ctx context.Context, m messagecollector.Measurement) error {
			panic("mock out the Save method")
		},
		SaveManyFunc: func(ctx context.Context, m []messagecollector.Measurement) error {
			panic("mock out the SaveMany method")
		},
	}

	// use mockedStorage in code that requires Storage
	// and then make assertions.

}

func (*StorageMock) Query

Query calls QueryFunc.

func (*StorageMock) QueryCalls

func (mock *StorageMock) QueryCalls() []struct {
	Ctx     context.Context
	Q       messagecollector.QueryParams
	Tenants []string
}

QueryCalls gets all the calls that were made to Query. Check the length with:

len(mockedStorage.QueryCalls())

func (*StorageMock) QueryDevice

func (mock *StorageMock) QueryDevice(ctx context.Context, deviceID string, tenants []string) messagecollector.QueryResult

QueryDevice calls QueryDeviceFunc.

func (*StorageMock) QueryDeviceCalls

func (mock *StorageMock) QueryDeviceCalls() []struct {
	Ctx      context.Context
	DeviceID string
	Tenants  []string
}

QueryDeviceCalls gets all the calls that were made to QueryDevice. Check the length with:

len(mockedStorage.QueryDeviceCalls())

func (*StorageMock) QueryObject

func (mock *StorageMock) QueryObject(ctx context.Context, deviceID string, urn string, tenants []string) messagecollector.QueryResult

QueryObject calls QueryObjectFunc.

func (*StorageMock) QueryObjectCalls

func (mock *StorageMock) QueryObjectCalls() []struct {
	Ctx      context.Context
	DeviceID string
	Urn      string
	Tenants  []string
}

QueryObjectCalls gets all the calls that were made to QueryObject. Check the length with:

len(mockedStorage.QueryObjectCalls())

func (*StorageMock) Save

Save calls SaveFunc.

func (*StorageMock) SaveCalls

func (mock *StorageMock) SaveCalls() []struct {
	Ctx context.Context
	M   messagecollector.Measurement
}

SaveCalls gets all the calls that were made to Save. Check the length with:

len(mockedStorage.SaveCalls())

func (*StorageMock) SaveMany

func (mock *StorageMock) SaveMany(ctx context.Context, m []messagecollector.Measurement) error

SaveMany calls SaveManyFunc.

func (*StorageMock) SaveManyCalls

func (mock *StorageMock) SaveManyCalls() []struct {
	Ctx context.Context
	M   []messagecollector.Measurement
}

SaveManyCalls gets all the calls that were made to SaveMany. Check the length with:

len(mockedStorage.SaveManyCalls())

Jump to

Keyboard shortcuts

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