Documentation ¶
Overview ¶
Package admin defines and implements store for admin-level data like secret key, list of admins and so on
Index ¶
- type EventType
- type RPC
- type StaticStore
- func (s *StaticStore) Admins(string) (ids []string, err error)
- func (s *StaticStore) Email(string) (email string, err error)
- func (s *StaticStore) Enabled(site string) (ok bool, err error)
- func (s *StaticStore) Key(_ string) (key string, err error)
- func (s *StaticStore) OnEvent(_ string, _ EventType) error
- type Store
- type StoreMock
- func (mock *StoreMock) Admins(siteID string) ([]string, error)
- func (mock *StoreMock) AdminsCalls() []struct{ ... }
- func (mock *StoreMock) Email(siteID string) (string, error)
- func (mock *StoreMock) EmailCalls() []struct{ ... }
- func (mock *StoreMock) Enabled(siteID string) (bool, error)
- func (mock *StoreMock) EnabledCalls() []struct{ ... }
- func (mock *StoreMock) Key(siteID string) (string, error)
- func (mock *StoreMock) KeyCalls() []struct{ ... }
- func (mock *StoreMock) OnEvent(siteID string, et EventType) error
- func (mock *StoreMock) OnEventCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RPC ¶
RPC implements remote engine and delegates all Calls to remote http server
type StaticStore ¶
type StaticStore struct {
// contains filtered or unexported fields
}
StaticStore implements keys.Store with a single set of admins and email for all sites
func NewStaticKeyStore ¶
func NewStaticKeyStore(key string) *StaticStore
NewStaticKeyStore is a shortcut for making StaticStore for key consumers only
func NewStaticStore ¶
func NewStaticStore(key string, sites, adminIDs []string, email string) *StaticStore
NewStaticStore makes StaticStore instance with given key
func (*StaticStore) Admins ¶
func (s *StaticStore) Admins(string) (ids []string, err error)
Admins returns static list of admin ids, the same for all sites
func (*StaticStore) Email ¶
func (s *StaticStore) Email(string) (email string, err error)
Email gets static email address
func (*StaticStore) Enabled ¶
func (s *StaticStore) Enabled(site string) (ok bool, err error)
Enabled if always true for StaticStore
type Store ¶
type Store interface { Key(siteID string) (key string, err error) Admins(siteID string) (ids []string, err error) Email(siteID string) (email string, err error) Enabled(siteID string) (ok bool, err error) OnEvent(siteID string, et EventType) error }
Store defines interface returning admins info for given site
type StoreMock ¶ added in v1.13.0
type StoreMock struct { // AdminsFunc mocks the Admins method. AdminsFunc func(siteID string) ([]string, error) // EmailFunc mocks the Email method. EmailFunc func(siteID string) (string, error) // EnabledFunc mocks the Enabled method. EnabledFunc func(siteID string) (bool, error) // KeyFunc mocks the Key method. KeyFunc func(siteID string) (string, error) // OnEventFunc mocks the OnEvent method. OnEventFunc func(siteID string, et EventType) 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{ AdminsFunc: func(siteID string) ([]string, error) { panic("mock out the Admins method") }, EmailFunc: func(siteID string) (string, error) { panic("mock out the Email method") }, EnabledFunc: func(siteID string) (bool, error) { panic("mock out the Enabled method") }, KeyFunc: func(siteID string) (string, error) { panic("mock out the Key method") }, OnEventFunc: func(siteID string, et EventType) error { panic("mock out the OnEvent method") }, } // use mockedStore in code that requires Store // and then make assertions. }
func (*StoreMock) AdminsCalls ¶ added in v1.13.0
AdminsCalls gets all the calls that were made to Admins. Check the length with:
len(mockedStore.AdminsCalls())
func (*StoreMock) EmailCalls ¶ added in v1.13.0
EmailCalls gets all the calls that were made to Email. Check the length with:
len(mockedStore.EmailCalls())
func (*StoreMock) EnabledCalls ¶ added in v1.13.0
EnabledCalls gets all the calls that were made to Enabled. Check the length with:
len(mockedStore.EnabledCalls())
func (*StoreMock) KeyCalls ¶ added in v1.13.0
KeyCalls gets all the calls that were made to Key. Check the length with:
len(mockedStore.KeyCalls())
func (*StoreMock) OnEventCalls ¶ added in v1.13.0
OnEventCalls gets all the calls that were made to OnEvent. Check the length with:
len(mockedStore.OnEventCalls())