Documentation ¶
Overview ¶
Package test contains helper functions to test the other packages.
Index ¶
- func CmpIntSet(a, b map[int]bool) bool
- func CmpIntSlice(a, b []int) bool
- func CmpStrSlice(a, b []string) bool
- func ExampleData() map[string]json.RawMessage
- func ExpectEqualJSON(t *testing.T, a, b []byte)
- type AutherMock
- type DatastoreMock
- func (d *DatastoreMock) Change(keys []string)
- func (d *DatastoreMock) ChangedKeys(from, to int) ([]string, error)
- func (d *DatastoreMock) ConfigValue(key string, value interface{}) error
- func (d *DatastoreMock) CurrentID() int
- func (d *DatastoreMock) Get(collection string, id int, v interface{}) error
- func (d *DatastoreMock) GetAll() map[string]json.RawMessage
- func (d *DatastoreMock) GetCollection(collection string) []json.RawMessage
- func (d *DatastoreMock) GetMany(keys []string) map[string]json.RawMessage
- func (d *DatastoreMock) GetModels(collection string, ids []int) []json.RawMessage
- func (d *DatastoreMock) KeysChanged() ([]string, int, error)
- func (d *DatastoreMock) LowestID() int
- func (d *DatastoreMock) ProjectorData(ctx context.Context, tid uint64) (uint64, map[int]json.RawMessage, error)
- type HasPermMock
- func (h *HasPermMock) ConfigValue(key string, v interface{}) error
- func (h *HasPermMock) Get(collection string, id int, v interface{}) error
- func (h *HasPermMock) HasPerm(_ int, perm string) bool
- func (h *HasPermMock) InGroups(_ int, groups []int) bool
- func (h *HasPermMock) IsSuperadmin(_ int) bool
- func (h *HasPermMock) UserRequired(uid int) []string
- type ProjectorDataset
- type RedisMock
- func (r *RedisMock) ChangedKeys(from, to int) ([]string, error)
- func (r *RedisMock) Data(keys []string) (map[string]json.RawMessage, error)
- func (r *RedisMock) FullData() (data map[string]json.RawMessage, max int, min int, err error)
- func (r *RedisMock) Send(value []byte)
- func (r *RedisMock) Update(closing <-chan struct{}) ([]byte, error)
- type RequiredUserDataset
- type RestrictedDataset
- type RestricterMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CmpIntSlice ¶
CmpIntSlice returns true, if both slices have the same values.
func CmpStrSlice ¶
CmpStrSlice returns true, if both slices have the same values.
func ExampleData ¶
func ExampleData() map[string]json.RawMessage
ExampleData returns a full database with example data.
func ExpectEqualJSON ¶
ExpectEqualJSON tests, that a and b are the same json elements.
Types ¶
type AutherMock ¶
type AutherMock struct{}
AutherMock implements the autoupdate.Auther interface.
func (*AutherMock) Authenticate ¶
Authenticate returns the request context.
type DatastoreMock ¶
type DatastoreMock struct { FullData map[string]json.RawMessage Err error // contains filtered or unexported fields }
DatastoreMock implements the autoupdate.Datastore interface.
func NewDatastoreMock ¶
func NewDatastoreMock(startID int, closed <-chan struct{}) *DatastoreMock
NewDatastoreMock initializes a DatastoreMock.
func (*DatastoreMock) Change ¶
func (d *DatastoreMock) Change(keys []string)
Change sends an update event for KeysChanged.
func (*DatastoreMock) ChangedKeys ¶
func (d *DatastoreMock) ChangedKeys(from, to int) ([]string, error)
ChangedKeys does nothing...
func (*DatastoreMock) ConfigValue ¶
func (d *DatastoreMock) ConfigValue(key string, value interface{}) error
ConfigValue sets v to the value of config value key.
func (*DatastoreMock) CurrentID ¶
func (d *DatastoreMock) CurrentID() int
CurrentID returns the max id if the mock.
func (*DatastoreMock) Get ¶
func (d *DatastoreMock) Get(collection string, id int, v interface{}) error
Get sets v to the decoded value of collection:id
func (*DatastoreMock) GetAll ¶
func (d *DatastoreMock) GetAll() map[string]json.RawMessage
GetAll returns FullData.
func (*DatastoreMock) GetCollection ¶
func (d *DatastoreMock) GetCollection(collection string) []json.RawMessage
GetCollection gets all elements of one collection.
func (*DatastoreMock) GetMany ¶
func (d *DatastoreMock) GetMany(keys []string) map[string]json.RawMessage
GetMany returns the given keys from FullData.
func (*DatastoreMock) GetModels ¶
func (d *DatastoreMock) GetModels(collection string, ids []int) []json.RawMessage
GetModels returns each element from collection that is in the ids slide.
func (*DatastoreMock) KeysChanged ¶
func (d *DatastoreMock) KeysChanged() ([]string, int, error)
KeysChanged waits for Changes to be called.
func (*DatastoreMock) LowestID ¶
func (d *DatastoreMock) LowestID() int
LowestID returns the max id if the mock.
func (*DatastoreMock) ProjectorData ¶
func (d *DatastoreMock) ProjectorData(ctx context.Context, tid uint64) (uint64, map[int]json.RawMessage, error)
ProjectorData does currently nothing.
type HasPermMock ¶
type HasPermMock struct { IsSuperuser bool Perms []string Groups map[int]bool Data map[string]json.RawMessage }
HasPermMock implements the restricter.HasPermer interface.
func (*HasPermMock) ConfigValue ¶
func (h *HasPermMock) ConfigValue(key string, v interface{}) error
ConfigValue is currently a stub until it is actually needed by the tests
func (*HasPermMock) Get ¶
func (h *HasPermMock) Get(collection string, id int, v interface{}) error
Get tells, if the given user has the ...
func (*HasPermMock) HasPerm ¶
func (h *HasPermMock) HasPerm(_ int, perm string) bool
HasPerm returns true, if the given perm is in the list of Perms.
func (*HasPermMock) InGroups ¶
func (h *HasPermMock) InGroups(_ int, groups []int) bool
InGroups checks if one of the id in groups is also in HasPermMock.Groups
func (*HasPermMock) IsSuperadmin ¶
func (h *HasPermMock) IsSuperadmin(_ int) bool
IsSuperadmin returns, if the user is superadmin.
func (*HasPermMock) UserRequired ¶
func (h *HasPermMock) UserRequired(uid int) []string
UserRequired checks for the given groups.
type ProjectorDataset ¶
type ProjectorDataset struct { Name string ElementName string Overwrite map[string]json.RawMessage Expected json.RawMessage }
ProjectorDataset is a test case.
func ExampleProjector ¶
func ExampleProjector() []ProjectorDataset
ExampleProjector returns test cases.
type RedisMock ¶
type RedisMock struct { FD map[string]json.RawMessage Min int Max int ChangedKeysResult []string // contains filtered or unexported fields }
RedisMock implements the datastore.RedisConn interface.
func (*RedisMock) ChangedKeys ¶
ChangedKeys returnes ChangedKeysResult.
type RequiredUserDataset ¶
type RequiredUserDataset struct { Name string Collection string Element json.RawMessage ExpectPerm string ExpectIDs map[int]bool }
RequiredUserDataset is a testcase.
func ExampleRequiredUser ¶
func ExampleRequiredUser() []RequiredUserDataset
ExampleRequiredUser returns testcases to test required users.
type RestrictedDataset ¶
type RestrictedDataset struct { Name string UID int Permer *HasPermMock Collection string Element json.RawMessage Expected json.RawMessage }
RestrictedDataset is a used for a test.
func ExampleRestrictedData ¶
func ExampleRestrictedData() []RestrictedDataset
ExampleRestrictedData returns a list of Data for restricted data tests for an user.
type RestricterMock ¶
type RestricterMock struct {
Called bool
}
RestricterMock implements the autoupdate.Restrict interface.
func (*RestricterMock) Restrict ¶
func (r *RestricterMock) Restrict(uid int, data map[string]json.RawMessage)
Restrict does nothing.