corestorage

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert interface {
	// Update exists alert or create new
	Update(name string, level alert.Level) (*alert.Alert, bool, error)
	Index(levels []alert.Level) (alert.Alerts, error)
	Get(name string) (*alert.Alert, error)
}

Alert is an interface for Alert storage

type AlertMock

type AlertMock struct {
	// GetFunc mocks the Get method.
	GetFunc func(name string) (*alert.Alert, error)

	// IndexFunc mocks the Index method.
	IndexFunc func(levels []alert.Level) (alert.Alerts, error)

	// UpdateFunc mocks the Update method.
	UpdateFunc func(name string, level alert.Level) (*alert.Alert, bool, error)
	// contains filtered or unexported fields
}

AlertMock is a mock implementation of Alert.

func TestSomethingThatUsesAlert(t *testing.T) {

	// make and configure a mocked Alert
	mockedAlert := &AlertMock{
		GetFunc: func(name string) (*alert.Alert, error) {
			panic("mock out the Get method")
		},
		IndexFunc: func(levels []alert.Level) (alert.Alerts, error) {
			panic("mock out the Index method")
		},
		UpdateFunc: func(name string, level alert.Level) (*alert.Alert, bool, error) {
			panic("mock out the Update method")
		},
	}

	// use mockedAlert in code that requires Alert
	// and then make assertions.

}

func (*AlertMock) Get

func (mock *AlertMock) Get(name string) (*alert.Alert, error)

Get calls GetFunc.

func (*AlertMock) GetCalls added in v0.9.3

func (mock *AlertMock) GetCalls() []struct {
	Name string
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedAlert.GetCalls())

func (*AlertMock) Index added in v0.7.0

func (mock *AlertMock) Index(levels []alert.Level) (alert.Alerts, error)

Index calls IndexFunc.

func (*AlertMock) IndexCalls added in v0.9.3

func (mock *AlertMock) IndexCalls() []struct {
	Levels []alert.Level
}

IndexCalls gets all the calls that were made to Index. Check the length with:

len(mockedAlert.IndexCalls())

func (*AlertMock) Update added in v0.7.0

func (mock *AlertMock) Update(name string, level alert.Level) (*alert.Alert, bool, error)

Update calls UpdateFunc.

func (*AlertMock) UpdateCalls added in v0.9.3

func (mock *AlertMock) UpdateCalls() []struct {
	Name  string
	Level alert.Level
}

UpdateCalls gets all the calls that were made to Update. Check the length with:

len(mockedAlert.UpdateCalls())

type CoreStorage

type CoreStorage interface {
	Name() string
	KV() KV
	Alert() Alert
	Stop() error
}

CoreStorage is an interface for the CoreStorage

type CoreStorageMock added in v0.9.3

type CoreStorageMock struct {
	// AlertFunc mocks the Alert method.
	AlertFunc func() Alert

	// KVFunc mocks the KV method.
	KVFunc func() KV

	// NameFunc mocks the Name method.
	NameFunc func() string

	// StopFunc mocks the Stop method.
	StopFunc func() error
	// contains filtered or unexported fields
}

CoreStorageMock is a mock implementation of CoreStorage.

func TestSomethingThatUsesCoreStorage(t *testing.T) {

	// make and configure a mocked CoreStorage
	mockedCoreStorage := &CoreStorageMock{
		AlertFunc: func() Alert {
			panic("mock out the Alert method")
		},
		KVFunc: func() KV {
			panic("mock out the KV method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		StopFunc: func() error {
			panic("mock out the Stop method")
		},
	}

	// use mockedCoreStorage in code that requires CoreStorage
	// and then make assertions.

}

func (*CoreStorageMock) Alert added in v0.9.3

func (mock *CoreStorageMock) Alert() Alert

Alert calls AlertFunc.

func (*CoreStorageMock) AlertCalls added in v0.9.3

func (mock *CoreStorageMock) AlertCalls() []struct {
}

AlertCalls gets all the calls that were made to Alert. Check the length with:

len(mockedCoreStorage.AlertCalls())

func (*CoreStorageMock) KV added in v0.9.3

func (mock *CoreStorageMock) KV() KV

KV calls KVFunc.

func (*CoreStorageMock) KVCalls added in v0.9.3

func (mock *CoreStorageMock) KVCalls() []struct {
}

KVCalls gets all the calls that were made to KV. Check the length with:

len(mockedCoreStorage.KVCalls())

func (*CoreStorageMock) Name added in v0.9.3

func (mock *CoreStorageMock) Name() string

Name calls NameFunc.

func (*CoreStorageMock) NameCalls added in v0.9.3

func (mock *CoreStorageMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedCoreStorage.NameCalls())

func (*CoreStorageMock) Stop added in v0.9.3

func (mock *CoreStorageMock) Stop() error

Stop calls StopFunc.

func (*CoreStorageMock) StopCalls added in v0.9.3

func (mock *CoreStorageMock) StopCalls() []struct {
}

StopCalls gets all the calls that were made to Stop. Check the length with:

len(mockedCoreStorage.StopCalls())

type KV

type KV interface {
	Put(string, string) error
	Get(string) (string, error)
	Upsert(string, string) error
	Delete(string) error
	All() (map[string]string, error)
}

KV is an interface for KV storage

type KVMock

type KVMock struct {
	// AllFunc mocks the All method.
	AllFunc func() (map[string]string, error)

	// DeleteFunc mocks the Delete method.
	DeleteFunc func(s string) error

	// GetFunc mocks the Get method.
	GetFunc func(s string) (string, error)

	// PutFunc mocks the Put method.
	PutFunc func(s1 string, s2 string) error

	// UpsertFunc mocks the Upsert method.
	UpsertFunc func(s1 string, s2 string) error
	// contains filtered or unexported fields
}

KVMock is a mock implementation of KV.

func TestSomethingThatUsesKV(t *testing.T) {

	// make and configure a mocked KV
	mockedKV := &KVMock{
		AllFunc: func() (map[string]string, error) {
			panic("mock out the All method")
		},
		DeleteFunc: func(s string) error {
			panic("mock out the Delete method")
		},
		GetFunc: func(s string) (string, error) {
			panic("mock out the Get method")
		},
		PutFunc: func(s1 string, s2 string) error {
			panic("mock out the Put method")
		},
		UpsertFunc: func(s1 string, s2 string) error {
			panic("mock out the Upsert method")
		},
	}

	// use mockedKV in code that requires KV
	// and then make assertions.

}

func (*KVMock) All

func (mock *KVMock) All() (map[string]string, error)

All calls AllFunc.

func (*KVMock) AllCalls added in v0.9.3

func (mock *KVMock) AllCalls() []struct {
}

AllCalls gets all the calls that were made to All. Check the length with:

len(mockedKV.AllCalls())

func (*KVMock) Delete

func (mock *KVMock) Delete(s string) error

Delete calls DeleteFunc.

func (*KVMock) DeleteCalls added in v0.9.3

func (mock *KVMock) DeleteCalls() []struct {
	S string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedKV.DeleteCalls())

func (*KVMock) Get

func (mock *KVMock) Get(s string) (string, error)

Get calls GetFunc.

func (*KVMock) GetCalls added in v0.9.3

func (mock *KVMock) GetCalls() []struct {
	S string
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedKV.GetCalls())

func (*KVMock) Put

func (mock *KVMock) Put(s1 string, s2 string) error

Put calls PutFunc.

func (*KVMock) PutCalls added in v0.9.3

func (mock *KVMock) PutCalls() []struct {
	S1 string
	S2 string
}

PutCalls gets all the calls that were made to Put. Check the length with:

len(mockedKV.PutCalls())

func (*KVMock) Upsert

func (mock *KVMock) Upsert(s1 string, s2 string) error

Upsert calls UpsertFunc.

func (*KVMock) UpsertCalls added in v0.9.3

func (mock *KVMock) UpsertCalls() []struct {
	S1 string
	S2 string
}

UpsertCalls gets all the calls that were made to Upsert. Check the length with:

len(mockedKV.UpsertCalls())

Directories

Path Synopsis
provider
sql

Jump to

Keyboard shortcuts

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