skydbtest

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectDBExtendSchema added in v1.1.0

func ExpectDBExtendSchema(db *mock_skydb.MockTxDatabase, extendedSchema skydb.RecordSchema)

func ExpectDBSaveUser added in v1.1.0

func ExpectDBSaveUser(db *mock_skydb.MockTxDatabase, extendedSchema *skydb.RecordSchema, assertSavedUserRecord interface{}, saveError error)

Types

type MapConn

type MapConn struct {
	UserMap          map[string]skydb.AuthInfo
	AssetMap         map[string]skydb.Asset
	InternalPublicDB skydb.Database

	OAuthMap           map[string]skydb.OAuthInfo
	CustomTokenInfoMap map[string]skydb.CustomTokenInfo
	skydb.Conn
	// contains filtered or unexported fields
}

MapConn is a naive memory implementation of skydb.Conn

func NewMapConn

func NewMapConn() *MapConn

NewMapConn returns a new MapConn.

func (*MapConn) AddRelation

func (conn *MapConn) AddRelation(user string, name string, targetUser string) error

AddRelation is not implemented.

func (*MapConn) Close

func (conn *MapConn) Close() error

Close does nothing.

func (*MapConn) CreateAuth added in v1.1.0

func (conn *MapConn) CreateAuth(authinfo *skydb.AuthInfo) error

CreateAuth creates a AuthInfo in UserMap.

func (*MapConn) CreateCustomTokenInfo added in v1.3.0

func (conn *MapConn) CreateCustomTokenInfo(tokenInfo *skydb.CustomTokenInfo) error

func (*MapConn) CreateOAuthInfo added in v1.2.0

func (conn *MapConn) CreateOAuthInfo(oauthinfo *skydb.OAuthInfo) (err error)

CreateOAuthInfo creates OAuthInfo in OAuthMap.

func (*MapConn) DeleteAuth added in v1.1.0

func (conn *MapConn) DeleteAuth(id string) error

DeleteAuth remove an existing in UserMap.

func (*MapConn) DeleteCustomTokenInfo added in v1.3.0

func (conn *MapConn) DeleteCustomTokenInfo(principalID string) error

func (*MapConn) DeleteDevice

func (conn *MapConn) DeleteDevice(id string) error

DeleteDevice is not implemented.

func (*MapConn) DeleteDevicesByToken

func (conn *MapConn) DeleteDevicesByToken(token string, t time.Time) error

DeleteDevicesByToken is not implemented.

func (*MapConn) DeleteEmptyDevicesByTime

func (conn *MapConn) DeleteEmptyDevicesByTime(t time.Time) error

DeleteEmptyDevicesByTime is not implemented.

func (*MapConn) DeleteOAuth added in v1.2.0

func (conn *MapConn) DeleteOAuth(provider string, principalID string) error

DeleteOAuth remove an existing in OAuthMap.

func (*MapConn) EnsureAuthRecordKeysValid added in v1.1.0

func (conn *MapConn) EnsureAuthRecordKeysValid(authRecordKeys [][]string) error

func (*MapConn) GetAdminRoles

func (conn *MapConn) GetAdminRoles() ([]string, error)

GetAdminRoles is not implemented.

func (*MapConn) GetAsset

func (conn *MapConn) GetAsset(name string, asset *skydb.Asset) error

GetAsset is not implemented.

func (*MapConn) GetAssets added in v0.22.2

func (conn *MapConn) GetAssets(names []string) ([]skydb.Asset, error)

GetAssets always returns empty array.

func (*MapConn) GetAuth added in v1.1.0

func (conn *MapConn) GetAuth(id string, authinfo *skydb.AuthInfo) error

GetAuth returns a AuthInfo in UserMap.

func (*MapConn) GetAuthByPrincipalID added in v1.1.0

func (conn *MapConn) GetAuthByPrincipalID(principalID string, authinfo *skydb.AuthInfo) error

GetAuthByPrincipalID returns a AuthInfo by its principalID.

func (*MapConn) GetCustomTokenInfo added in v1.3.0

func (conn *MapConn) GetCustomTokenInfo(principalID string, tokenInfo *skydb.CustomTokenInfo) error

func (*MapConn) GetDefaultRoles

func (conn *MapConn) GetDefaultRoles() ([]string, error)

GetDefaultRoles always return user for testing

func (*MapConn) GetDevice

func (conn *MapConn) GetDevice(id string, device *skydb.Device) error

GetDevice is not implemented.

func (*MapConn) GetOAuthInfo added in v1.2.0

func (conn *MapConn) GetOAuthInfo(provider string, principalID string, oauthinfo *skydb.OAuthInfo) error

GetOAuthInfo returns OAuthInfo by provider and principalID.

func (*MapConn) GetOAuthInfoByProviderAndUserID added in v1.2.0

func (conn *MapConn) GetOAuthInfoByProviderAndUserID(provider string, userID string, oauthinfo *skydb.OAuthInfo) error

GetOAuthInfoByProviderAndUserID returns OAuthInfo by provider and userID.

func (*MapConn) GetRecordAccess

func (conn *MapConn) GetRecordAccess(recordType string) (skydb.RecordACL, error)

GetRecordAccess returns record creation access of a specific type

func (*MapConn) GetRecordDefaultAccess added in v0.23.0

func (conn *MapConn) GetRecordDefaultAccess(recordType string) (skydb.RecordACL, error)

GetRecordDefaultAccess returns record default access of a specific type

func (*MapConn) GetRecordFieldAccess added in v1.1.0

func (conn *MapConn) GetRecordFieldAccess() (skydb.FieldACL, error)

GetRecordFieldAccess returns record field access for all types

func (*MapConn) PrivateDB

func (conn *MapConn) PrivateDB(userKey string) skydb.Database

PrivateDB is not implemented.

func (*MapConn) PublicDB

func (conn *MapConn) PublicDB() skydb.Database

PublicDB is not implemented.

func (*MapConn) QueryDevicesByUser

func (conn *MapConn) QueryDevicesByUser(user string) ([]skydb.Device, error)

QueryDevicesByUser is not implemented.

func (*MapConn) QueryRelation

func (conn *MapConn) QueryRelation(user string, name string, direction string, config skydb.QueryConfig) []skydb.AuthInfo

QueryRelation is not implemented.

func (*MapConn) QueryRelationCount

func (conn *MapConn) QueryRelationCount(user string, name string, direction string) (uint64, error)

QueryRelationCount is not implemented.

func (*MapConn) RemoveRelation

func (conn *MapConn) RemoveRelation(user string, name string, targetUser string) error

RemoveRelation is not implemented.

func (*MapConn) SaveAsset

func (conn *MapConn) SaveAsset(asset *skydb.Asset) error

SaveAsset is not implemented.

func (*MapConn) SaveDevice

func (conn *MapConn) SaveDevice(device *skydb.Device) error

SaveDevice is not implemented.

func (*MapConn) SetAdminRoles

func (conn *MapConn) SetAdminRoles(roles []string) error

SetAdminRoles is not implemented.

func (*MapConn) SetDefaultRoles

func (conn *MapConn) SetDefaultRoles(roles []string) error

SetDefaultRoles is not implemented.

func (*MapConn) SetRecordAccess

func (conn *MapConn) SetRecordAccess(recordType string, acl skydb.RecordACL) error

SetRecordAccess sets record creation access

func (*MapConn) SetRecordDefaultAccess added in v0.23.0

func (conn *MapConn) SetRecordDefaultAccess(recordType string, acl skydb.RecordACL) error

SetRecordDefaultAccess sets record creation access

func (*MapConn) SetRecordFieldAccess added in v1.1.0

func (conn *MapConn) SetRecordFieldAccess(acl skydb.FieldACL) error

SetRecordFieldAccess sets record field access for all types

func (*MapConn) Subscribe

func (conn *MapConn) Subscribe(recordEventChan chan skydb.RecordEvent) error

Subscribe is not implemented.

func (*MapConn) UpdateAuth added in v1.1.0

func (conn *MapConn) UpdateAuth(authinfo *skydb.AuthInfo) error

UpdateAuth updates an existing AuthInfo in UserMap.

func (*MapConn) UpdateOAuthInfo added in v1.2.0

func (conn *MapConn) UpdateOAuthInfo(oauthinfo *skydb.OAuthInfo) (err error)

UpdateOAuthInfo updates an existing OAuthInfo in OAuthMap.

type MapDB

type MapDB struct {
	RecordMap       RecordMap
	SubscriptionMap SubscriptionMap
	RecordSchemaMap RecordSchemaMap
	DBConn          skydb.Conn
	skydb.Database
}

MapDB is a naive memory implementation of skydb.Database.

func NewMapDB

func NewMapDB() *MapDB

NewMapDB returns a new MapDB ready for use.

func (*MapDB) DatabaseType

func (db *MapDB) DatabaseType() skydb.DatabaseType

func (*MapDB) Delete

func (db *MapDB) Delete(id skydb.RecordID) error

Delete remove the specified key from RecordMap.

func (*MapDB) DeleteSchema

func (db *MapDB) DeleteSchema(recordType, columnName string) error

func (*MapDB) DeleteSubscription

func (db *MapDB) DeleteSubscription(name string, deviceID string) error

DeleteSubscription deletes the specified key from SubscriptionMap.

func (*MapDB) Extend

func (db *MapDB) Extend(recordType string, schema skydb.RecordSchema) (bool, error)

Extend store the type of the field.

func (*MapDB) Get

func (db *MapDB) Get(id skydb.RecordID, record *skydb.Record) error

Get returns a Record from RecordMap.

func (*MapDB) GetRecordSchemas

func (db *MapDB) GetRecordSchemas() (map[string]skydb.RecordSchema, error)

GetRecordSchemas returns a list of all existing record type

func (*MapDB) GetSchema

func (db *MapDB) GetSchema(recordType string) (skydb.RecordSchema, error)

GetSchema returns the record schema of a record type

func (*MapDB) GetSubscription

func (db *MapDB) GetSubscription(name string, deviceID string, subscription *skydb.Subscription) error

GetSubscription return a Subscription from SubscriptionMap.

func (*MapDB) ID

func (db *MapDB) ID() string

ID returns a mock Database ID.

func (*MapDB) IsReadOnly

func (db *MapDB) IsReadOnly() bool

func (*MapDB) Query

func (db *MapDB) Query(query *skydb.Query, accessControlOptions *skydb.AccessControlOptions) (*skydb.Rows, error)

Query is not implemented.

func (*MapDB) RenameSchema

func (db *MapDB) RenameSchema(recordType, oldColumnName, newColumnName string) error

func (*MapDB) Save

func (db *MapDB) Save(record *skydb.Record) error

Save assigns Record to RecordMap.

func (*MapDB) SaveSubscription

func (db *MapDB) SaveSubscription(subscription *skydb.Subscription) error

SaveSubscription assigns to SubscriptionMap.

func (*MapDB) UserRecordType

func (db *MapDB) UserRecordType() string

type MockTxDatabase

type MockTxDatabase struct {
	DidBegin, DidCommit, DidRollback bool
	skydb.Database
}

MockTxDatabase implements and records TxDatabase's methods and delegates other calls to underlying Database

func NewMockTxDatabase

func NewMockTxDatabase(backingDB skydb.Database) *MockTxDatabase

func (*MockTxDatabase) Begin

func (db *MockTxDatabase) Begin() error

func (*MockTxDatabase) Commit

func (db *MockTxDatabase) Commit() error

func (*MockTxDatabase) Rollback

func (db *MockTxDatabase) Rollback() error

type RecordMap

type RecordMap map[string]skydb.Record

RecordMap is a string=>Record map

type RecordSchemaMap

type RecordSchemaMap map[string]skydb.RecordSchema

RecordSchemaMap is a string=>RecordSchema map

type SubscriptionMap

type SubscriptionMap map[string]skydb.Subscription

SubscriptionMap is a string=>Subscription map

Jump to

Keyboard shortcuts

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