fakes

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	MethodName string
	Arguments  []interface{}
}

type FakeAlertmanagerConfigStore

type FakeAlertmanagerConfigStore struct {
	Config models.AlertConfiguration
	// GetFn is an optional function that can be set to mock the GetLatestAlertmanagerConfiguration method
	GetFn func(ctx context.Context, orgID int64) (*models.AlertConfiguration, error)
	// UpdateFn is an optional function that can be set to mock the UpdateAlertmanagerConfiguration method
	UpdateFn func(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error
	// LastSaveCommand is the last command that was passed to UpdateAlertmanagerConfiguration
	LastSaveCommand *models.SaveAlertmanagerConfigurationCmd
}

func NewFakeAlertmanagerConfigStore

func NewFakeAlertmanagerConfigStore(config string) *FakeAlertmanagerConfigStore

func (*FakeAlertmanagerConfigStore) GetLatestAlertmanagerConfiguration

func (f *FakeAlertmanagerConfigStore) GetLatestAlertmanagerConfiguration(ctx context.Context, orgID int64) (*models.AlertConfiguration, error)

func (*FakeAlertmanagerConfigStore) UpdateAlertmanagerConfiguration

func (f *FakeAlertmanagerConfigStore) UpdateAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error

type FakeKVStore

type FakeKVStore struct {
	Mtx   sync.Mutex
	Store map[int64]map[string]map[string]string
}

func NewFakeKVStore

func NewFakeKVStore(t *testing.T) *FakeKVStore

func (*FakeKVStore) Del

func (fkv *FakeKVStore) Del(_ context.Context, orgId int64, namespace string, key string) error

func (*FakeKVStore) Get

func (fkv *FakeKVStore) Get(_ context.Context, orgId int64, namespace string, key string) (string, bool, error)

func (*FakeKVStore) GetAll

func (fkv *FakeKVStore) GetAll(ctx context.Context, orgId int64, namespace string) (map[int64]map[string]string, error)

func (*FakeKVStore) Keys

func (fkv *FakeKVStore) Keys(ctx context.Context, orgID int64, namespace string, keyPrefix string) ([]kvstore.Key, error)

func (*FakeKVStore) Set

func (fkv *FakeKVStore) Set(_ context.Context, orgId int64, namespace string, key string, value string) error

type FakeProvisioningStore

type FakeProvisioningStore struct {
	Records map[int64]map[string]models.Provenance
}

func NewFakeProvisioningStore

func NewFakeProvisioningStore() *FakeProvisioningStore

func (*FakeProvisioningStore) DeleteProvenance

func (f *FakeProvisioningStore) DeleteProvenance(ctx context.Context, o models.Provisionable, org int64) error

func (*FakeProvisioningStore) GetProvenance

func (*FakeProvisioningStore) GetProvenances

func (f *FakeProvisioningStore) GetProvenances(ctx context.Context, orgID int64, resourceType string) (map[string]models.Provenance, error)

func (*FakeProvisioningStore) SetProvenance

type FakeReceiverService

type FakeReceiverService struct {
	MethodCalls    []ReceiverServiceMethodCall
	GetReceiverFn  func(ctx context.Context, q models.GetReceiverQuery, u identity.Requester) (definitions.GettableApiReceiver, error)
	GetReceiversFn func(ctx context.Context, q models.GetReceiversQuery, u identity.Requester) ([]definitions.GettableApiReceiver, error)
}

func NewFakeReceiverService

func NewFakeReceiverService() *FakeReceiverService

func (*FakeReceiverService) PopMethodCall

func (*FakeReceiverService) Reset

func (f *FakeReceiverService) Reset()

type FakeSilenceStore

type FakeSilenceStore struct {
	Silences       map[string]*models.Silence
	RuleUIDFolders map[string]string

	RecordedOps []GenericRecordedQuery
}

func (*FakeSilenceStore) CreateSilence

func (s *FakeSilenceStore) CreateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error)

func (*FakeSilenceStore) DeleteSilence

func (s *FakeSilenceStore) DeleteSilence(ctx context.Context, orgID int64, id string) error

func (*FakeSilenceStore) GetSilence

func (s *FakeSilenceStore) GetSilence(ctx context.Context, orgID int64, id string) (*models.Silence, error)

func (*FakeSilenceStore) ListSilences

func (s *FakeSilenceStore) ListSilences(ctx context.Context, orgID int64, filter []string) ([]*models.Silence, error)

func (*FakeSilenceStore) UpdateSilence

func (s *FakeSilenceStore) UpdateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error)

type GenericRecordedQuery

type GenericRecordedQuery struct {
	Name   string
	Params []any
}

type ReceiverServiceMethodCall

type ReceiverServiceMethodCall struct {
	Method string
	Args   []interface{}
}

type RuleStore

type RuleStore struct {

	// OrgID -> RuleGroup -> Namespace -> Rules
	Rules       map[int64][]*models.AlertRule
	Hook        func(cmd any) error // use Hook if you need to intercept some query and return an error
	RecordedOps []any
	Folders     map[int64][]*folder.Folder
	// contains filtered or unexported fields
}

FakeRuleStore mocks the RuleStore of the scheduler.

func NewRuleStore

func NewRuleStore(t *testing.T) *RuleStore

func (*RuleStore) CountInFolders

func (f *RuleStore) CountInFolders(ctx context.Context, orgID int64, folderUIDs []string, u identity.Requester) (int64, error)

func (*RuleStore) DeleteAlertRulesByUID

func (f *RuleStore) DeleteAlertRulesByUID(_ context.Context, orgID int64, UIDs ...string) error

func (*RuleStore) GetAlertRuleByUID

func (f *RuleStore) GetAlertRuleByUID(_ context.Context, q *models.GetAlertRuleByUIDQuery) (*models.AlertRule, error)

func (*RuleStore) GetAlertRulesGroupByRuleUID

func (f *RuleStore) GetAlertRulesGroupByRuleUID(_ context.Context, q *models.GetAlertRulesGroupByRuleUIDQuery) ([]*models.AlertRule, error)

func (*RuleStore) GetNamespaceByUID

func (f *RuleStore) GetNamespaceByUID(_ context.Context, uid string, orgID int64, user identity.Requester) (*folder.Folder, error)

func (*RuleStore) GetNamespacesByRuleUID

func (f *RuleStore) GetNamespacesByRuleUID(ctx context.Context, orgID int64, uids ...string) (map[string]string, error)

func (*RuleStore) GetRecordedCommands

func (f *RuleStore) GetRecordedCommands(predicate func(cmd any) (any, bool)) []any

GetRecordedCommands filters recorded commands using predicate function. Returns the subset of the recorded commands that meet the predicate

func (*RuleStore) GetRuleGroupInterval

func (f *RuleStore) GetRuleGroupInterval(ctx context.Context, orgID int64, namespaceUID string, ruleGroup string) (int64, error)

func (*RuleStore) GetUserVisibleNamespaces

func (f *RuleStore) GetUserVisibleNamespaces(_ context.Context, orgID int64, _ identity.Requester) (map[string]*folder.Folder, error)

func (*RuleStore) InTransaction

func (f *RuleStore) InTransaction(ctx context.Context, fn func(c context.Context) error) error

func (*RuleStore) IncreaseVersionForAllRulesInNamespace

func (f *RuleStore) IncreaseVersionForAllRulesInNamespace(_ context.Context, orgID int64, namespaceUID string) ([]models.AlertRuleKeyWithVersion, error)

func (*RuleStore) InsertAlertRules

func (f *RuleStore) InsertAlertRules(_ context.Context, q []models.AlertRule) ([]models.AlertRuleKeyWithId, error)

func (*RuleStore) ListAlertRules

func (*RuleStore) PutRule

func (f *RuleStore) PutRule(_ context.Context, rules ...*models.AlertRule)

PutRule puts the rule in the Rules map. If there are existing rule in the same namespace, they will be overwritten

func (*RuleStore) UpdateAlertRules

func (f *RuleStore) UpdateAlertRules(_ context.Context, q []models.UpdateRule) error

func (*RuleStore) UpdateRuleGroup

func (f *RuleStore) UpdateRuleGroup(ctx context.Context, orgID int64, namespaceUID string, ruleGroup string, interval int64) error

Jump to

Keyboard shortcuts

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