Documentation ¶
Index ¶
- Variables
- type DB
- type MockDB
- func (_m *MockDB) CreateFile(ctx context.Context, file *snips.File, maxFiles uint64) error
- func (_m *MockDB) CreateUserWithPublicKey(ctx context.Context, publickey *snips.PublicKey) (*snips.User, error)
- func (_m *MockDB) DeleteFile(ctx context.Context, id string) error
- func (_m *MockDB) EXPECT() *MockDB_Expecter
- func (_m *MockDB) FindFile(ctx context.Context, id string) (*snips.File, error)
- func (_m *MockDB) FindFilesByUser(ctx context.Context, userID string) ([]*snips.File, error)
- func (_m *MockDB) FindPublicKeyByFingerprint(ctx context.Context, fingerprint string) (*snips.PublicKey, error)
- func (_m *MockDB) FindUser(ctx context.Context, id string) (*snips.User, error)
- func (_m *MockDB) Migrate(ctx context.Context) error
- func (_m *MockDB) UpdateFile(ctx context.Context, file *snips.File) error
- type MockDB_CreateFile_Call
- func (_c *MockDB_CreateFile_Call) Return(_a0 error) *MockDB_CreateFile_Call
- func (_c *MockDB_CreateFile_Call) Run(run func(ctx context.Context, file *snips.File, maxFiles uint64)) *MockDB_CreateFile_Call
- func (_c *MockDB_CreateFile_Call) RunAndReturn(run func(context.Context, *snips.File, uint64) error) *MockDB_CreateFile_Call
- type MockDB_CreateUserWithPublicKey_Call
- func (_c *MockDB_CreateUserWithPublicKey_Call) Return(_a0 *snips.User, _a1 error) *MockDB_CreateUserWithPublicKey_Call
- func (_c *MockDB_CreateUserWithPublicKey_Call) Run(run func(ctx context.Context, publickey *snips.PublicKey)) *MockDB_CreateUserWithPublicKey_Call
- func (_c *MockDB_CreateUserWithPublicKey_Call) RunAndReturn(run func(context.Context, *snips.PublicKey) (*snips.User, error)) *MockDB_CreateUserWithPublicKey_Call
- type MockDB_DeleteFile_Call
- type MockDB_Expecter
- func (_e *MockDB_Expecter) CreateFile(ctx interface{}, file interface{}, maxFiles interface{}) *MockDB_CreateFile_Call
- func (_e *MockDB_Expecter) CreateUserWithPublicKey(ctx interface{}, publickey interface{}) *MockDB_CreateUserWithPublicKey_Call
- func (_e *MockDB_Expecter) DeleteFile(ctx interface{}, id interface{}) *MockDB_DeleteFile_Call
- func (_e *MockDB_Expecter) FindFile(ctx interface{}, id interface{}) *MockDB_FindFile_Call
- func (_e *MockDB_Expecter) FindFilesByUser(ctx interface{}, userID interface{}) *MockDB_FindFilesByUser_Call
- func (_e *MockDB_Expecter) FindPublicKeyByFingerprint(ctx interface{}, fingerprint interface{}) *MockDB_FindPublicKeyByFingerprint_Call
- func (_e *MockDB_Expecter) FindUser(ctx interface{}, id interface{}) *MockDB_FindUser_Call
- func (_e *MockDB_Expecter) Migrate(ctx interface{}) *MockDB_Migrate_Call
- func (_e *MockDB_Expecter) UpdateFile(ctx interface{}, file interface{}) *MockDB_UpdateFile_Call
- type MockDB_FindFile_Call
- func (_c *MockDB_FindFile_Call) Return(_a0 *snips.File, _a1 error) *MockDB_FindFile_Call
- func (_c *MockDB_FindFile_Call) Run(run func(ctx context.Context, id string)) *MockDB_FindFile_Call
- func (_c *MockDB_FindFile_Call) RunAndReturn(run func(context.Context, string) (*snips.File, error)) *MockDB_FindFile_Call
- type MockDB_FindFilesByUser_Call
- func (_c *MockDB_FindFilesByUser_Call) Return(_a0 []*snips.File, _a1 error) *MockDB_FindFilesByUser_Call
- func (_c *MockDB_FindFilesByUser_Call) Run(run func(ctx context.Context, userID string)) *MockDB_FindFilesByUser_Call
- func (_c *MockDB_FindFilesByUser_Call) RunAndReturn(run func(context.Context, string) ([]*snips.File, error)) *MockDB_FindFilesByUser_Call
- type MockDB_FindPublicKeyByFingerprint_Call
- func (_c *MockDB_FindPublicKeyByFingerprint_Call) Return(_a0 *snips.PublicKey, _a1 error) *MockDB_FindPublicKeyByFingerprint_Call
- func (_c *MockDB_FindPublicKeyByFingerprint_Call) Run(run func(ctx context.Context, fingerprint string)) *MockDB_FindPublicKeyByFingerprint_Call
- func (_c *MockDB_FindPublicKeyByFingerprint_Call) RunAndReturn(run func(context.Context, string) (*snips.PublicKey, error)) *MockDB_FindPublicKeyByFingerprint_Call
- type MockDB_FindUser_Call
- func (_c *MockDB_FindUser_Call) Return(_a0 *snips.User, _a1 error) *MockDB_FindUser_Call
- func (_c *MockDB_FindUser_Call) Run(run func(ctx context.Context, id string)) *MockDB_FindUser_Call
- func (_c *MockDB_FindUser_Call) RunAndReturn(run func(context.Context, string) (*snips.User, error)) *MockDB_FindUser_Call
- type MockDB_Migrate_Call
- type MockDB_UpdateFile_Call
- func (_c *MockDB_UpdateFile_Call) Return(_a0 error) *MockDB_UpdateFile_Call
- func (_c *MockDB_UpdateFile_Call) Run(run func(ctx context.Context, file *snips.File)) *MockDB_UpdateFile_Call
- func (_c *MockDB_UpdateFile_Call) RunAndReturn(run func(context.Context, *snips.File) error) *MockDB_UpdateFile_Call
- type Sqlite
- func (s *Sqlite) CreateFile(ctx context.Context, file *snips.File, maxFileCount uint64) error
- func (s *Sqlite) CreateUserWithPublicKey(ctx context.Context, publickey *snips.PublicKey) (*snips.User, error)
- func (s *Sqlite) DeleteFile(ctx context.Context, id string) error
- func (s *Sqlite) FindFile(ctx context.Context, id string) (*snips.File, error)
- func (s *Sqlite) FindFilesByUser(ctx context.Context, userID string) ([]*snips.File, error)
- func (s *Sqlite) FindPublicKeyByFingerprint(ctx context.Context, fingerprint string) (*snips.PublicKey, error)
- func (s *Sqlite) FindUser(ctx context.Context, id string) (*snips.User, error)
- func (s *Sqlite) Migrate(ctx context.Context) error
- func (s *Sqlite) UpdateFile(ctx context.Context, file *snips.File) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrFileLimit = errors.New("file limit reached")
)
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Migrate migrates the database. Migrate(ctx context.Context) error // FindFile returns a file by its ID. Includes file content. FindFile(ctx context.Context, id string) (*snips.File, error) // CreateFile creates a new file. If a user has more than maxFiles, an error is returned. CreateFile(ctx context.Context, file *snips.File, maxFiles uint64) error // UpdateFile updates a file. UpdateFile(ctx context.Context, file *snips.File) error // DeleteFile deletes a file by its ID. DeleteFile(ctx context.Context, id string) error // FindFilesByUser returns all files for a user. Does not include file content. FindFilesByUser(ctx context.Context, userID string) ([]*snips.File, error) // FindPublicKeyByFingerprint returns a public key by its fingerprint. FindPublicKeyByFingerprint(ctx context.Context, fingerprint string) (*snips.PublicKey, error) // CreateUserWithPublicKey creates a new user with a public key. CreateUserWithPublicKey(ctx context.Context, publickey *snips.PublicKey) (*snips.User, error) // FindUser returns a user by its ID. FindUser(ctx context.Context, id string) (*snips.User, error) }
type MockDB ¶
MockDB is an autogenerated mock type for the DB type
func NewMockDB ¶
func NewMockDB(t mockConstructorTestingTNewMockDB) *MockDB
NewMockDB creates a new instance of MockDB. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockDB) CreateFile ¶
CreateFile provides a mock function with given fields: ctx, file, maxFiles
func (*MockDB) CreateUserWithPublicKey ¶
func (_m *MockDB) CreateUserWithPublicKey(ctx context.Context, publickey *snips.PublicKey) (*snips.User, error)
CreateUserWithPublicKey provides a mock function with given fields: ctx, publickey
func (*MockDB) DeleteFile ¶
DeleteFile provides a mock function with given fields: ctx, id
func (*MockDB) EXPECT ¶
func (_m *MockDB) EXPECT() *MockDB_Expecter
func (*MockDB) FindFilesByUser ¶
FindFilesByUser provides a mock function with given fields: ctx, userID
func (*MockDB) FindPublicKeyByFingerprint ¶
func (_m *MockDB) FindPublicKeyByFingerprint(ctx context.Context, fingerprint string) (*snips.PublicKey, error)
FindPublicKeyByFingerprint provides a mock function with given fields: ctx, fingerprint
type MockDB_CreateFile_Call ¶
MockDB_CreateFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateFile'
func (*MockDB_CreateFile_Call) Return ¶
func (_c *MockDB_CreateFile_Call) Return(_a0 error) *MockDB_CreateFile_Call
func (*MockDB_CreateFile_Call) Run ¶
func (_c *MockDB_CreateFile_Call) Run(run func(ctx context.Context, file *snips.File, maxFiles uint64)) *MockDB_CreateFile_Call
func (*MockDB_CreateFile_Call) RunAndReturn ¶
func (_c *MockDB_CreateFile_Call) RunAndReturn(run func(context.Context, *snips.File, uint64) error) *MockDB_CreateFile_Call
type MockDB_CreateUserWithPublicKey_Call ¶
MockDB_CreateUserWithPublicKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateUserWithPublicKey'
func (*MockDB_CreateUserWithPublicKey_Call) Return ¶
func (_c *MockDB_CreateUserWithPublicKey_Call) Return(_a0 *snips.User, _a1 error) *MockDB_CreateUserWithPublicKey_Call
func (*MockDB_CreateUserWithPublicKey_Call) Run ¶
func (_c *MockDB_CreateUserWithPublicKey_Call) Run(run func(ctx context.Context, publickey *snips.PublicKey)) *MockDB_CreateUserWithPublicKey_Call
func (*MockDB_CreateUserWithPublicKey_Call) RunAndReturn ¶
func (_c *MockDB_CreateUserWithPublicKey_Call) RunAndReturn(run func(context.Context, *snips.PublicKey) (*snips.User, error)) *MockDB_CreateUserWithPublicKey_Call
type MockDB_DeleteFile_Call ¶
MockDB_DeleteFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteFile'
func (*MockDB_DeleteFile_Call) Return ¶
func (_c *MockDB_DeleteFile_Call) Return(_a0 error) *MockDB_DeleteFile_Call
func (*MockDB_DeleteFile_Call) Run ¶
func (_c *MockDB_DeleteFile_Call) Run(run func(ctx context.Context, id string)) *MockDB_DeleteFile_Call
func (*MockDB_DeleteFile_Call) RunAndReturn ¶
func (_c *MockDB_DeleteFile_Call) RunAndReturn(run func(context.Context, string) error) *MockDB_DeleteFile_Call
type MockDB_Expecter ¶
type MockDB_Expecter struct {
// contains filtered or unexported fields
}
func (*MockDB_Expecter) CreateFile ¶
func (_e *MockDB_Expecter) CreateFile(ctx interface{}, file interface{}, maxFiles interface{}) *MockDB_CreateFile_Call
CreateFile is a helper method to define mock.On call
- ctx context.Context
- file *snips.File
- maxFiles uint64
func (*MockDB_Expecter) CreateUserWithPublicKey ¶
func (_e *MockDB_Expecter) CreateUserWithPublicKey(ctx interface{}, publickey interface{}) *MockDB_CreateUserWithPublicKey_Call
CreateUserWithPublicKey is a helper method to define mock.On call
- ctx context.Context
- publickey *snips.PublicKey
func (*MockDB_Expecter) DeleteFile ¶
func (_e *MockDB_Expecter) DeleteFile(ctx interface{}, id interface{}) *MockDB_DeleteFile_Call
DeleteFile is a helper method to define mock.On call
- ctx context.Context
- id string
func (*MockDB_Expecter) FindFile ¶
func (_e *MockDB_Expecter) FindFile(ctx interface{}, id interface{}) *MockDB_FindFile_Call
FindFile is a helper method to define mock.On call
- ctx context.Context
- id string
func (*MockDB_Expecter) FindFilesByUser ¶
func (_e *MockDB_Expecter) FindFilesByUser(ctx interface{}, userID interface{}) *MockDB_FindFilesByUser_Call
FindFilesByUser is a helper method to define mock.On call
- ctx context.Context
- userID string
func (*MockDB_Expecter) FindPublicKeyByFingerprint ¶
func (_e *MockDB_Expecter) FindPublicKeyByFingerprint(ctx interface{}, fingerprint interface{}) *MockDB_FindPublicKeyByFingerprint_Call
FindPublicKeyByFingerprint is a helper method to define mock.On call
- ctx context.Context
- fingerprint string
func (*MockDB_Expecter) FindUser ¶
func (_e *MockDB_Expecter) FindUser(ctx interface{}, id interface{}) *MockDB_FindUser_Call
FindUser is a helper method to define mock.On call
- ctx context.Context
- id string
func (*MockDB_Expecter) Migrate ¶
func (_e *MockDB_Expecter) Migrate(ctx interface{}) *MockDB_Migrate_Call
Migrate is a helper method to define mock.On call
- ctx context.Context
func (*MockDB_Expecter) UpdateFile ¶
func (_e *MockDB_Expecter) UpdateFile(ctx interface{}, file interface{}) *MockDB_UpdateFile_Call
UpdateFile is a helper method to define mock.On call
- ctx context.Context
- file *snips.File
type MockDB_FindFile_Call ¶
MockDB_FindFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindFile'
func (*MockDB_FindFile_Call) Return ¶
func (_c *MockDB_FindFile_Call) Return(_a0 *snips.File, _a1 error) *MockDB_FindFile_Call
func (*MockDB_FindFile_Call) Run ¶
func (_c *MockDB_FindFile_Call) Run(run func(ctx context.Context, id string)) *MockDB_FindFile_Call
func (*MockDB_FindFile_Call) RunAndReturn ¶
func (_c *MockDB_FindFile_Call) RunAndReturn(run func(context.Context, string) (*snips.File, error)) *MockDB_FindFile_Call
type MockDB_FindFilesByUser_Call ¶
MockDB_FindFilesByUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindFilesByUser'
func (*MockDB_FindFilesByUser_Call) Return ¶
func (_c *MockDB_FindFilesByUser_Call) Return(_a0 []*snips.File, _a1 error) *MockDB_FindFilesByUser_Call
func (*MockDB_FindFilesByUser_Call) Run ¶
func (_c *MockDB_FindFilesByUser_Call) Run(run func(ctx context.Context, userID string)) *MockDB_FindFilesByUser_Call
func (*MockDB_FindFilesByUser_Call) RunAndReturn ¶
func (_c *MockDB_FindFilesByUser_Call) RunAndReturn(run func(context.Context, string) ([]*snips.File, error)) *MockDB_FindFilesByUser_Call
type MockDB_FindPublicKeyByFingerprint_Call ¶
MockDB_FindPublicKeyByFingerprint_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindPublicKeyByFingerprint'
func (*MockDB_FindPublicKeyByFingerprint_Call) Return ¶
func (_c *MockDB_FindPublicKeyByFingerprint_Call) Return(_a0 *snips.PublicKey, _a1 error) *MockDB_FindPublicKeyByFingerprint_Call
func (*MockDB_FindPublicKeyByFingerprint_Call) Run ¶
func (_c *MockDB_FindPublicKeyByFingerprint_Call) Run(run func(ctx context.Context, fingerprint string)) *MockDB_FindPublicKeyByFingerprint_Call
func (*MockDB_FindPublicKeyByFingerprint_Call) RunAndReturn ¶
func (_c *MockDB_FindPublicKeyByFingerprint_Call) RunAndReturn(run func(context.Context, string) (*snips.PublicKey, error)) *MockDB_FindPublicKeyByFingerprint_Call
type MockDB_FindUser_Call ¶
MockDB_FindUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindUser'
func (*MockDB_FindUser_Call) Return ¶
func (_c *MockDB_FindUser_Call) Return(_a0 *snips.User, _a1 error) *MockDB_FindUser_Call
func (*MockDB_FindUser_Call) Run ¶
func (_c *MockDB_FindUser_Call) Run(run func(ctx context.Context, id string)) *MockDB_FindUser_Call
func (*MockDB_FindUser_Call) RunAndReturn ¶
func (_c *MockDB_FindUser_Call) RunAndReturn(run func(context.Context, string) (*snips.User, error)) *MockDB_FindUser_Call
type MockDB_Migrate_Call ¶
MockDB_Migrate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Migrate'
func (*MockDB_Migrate_Call) Return ¶
func (_c *MockDB_Migrate_Call) Return(_a0 error) *MockDB_Migrate_Call
func (*MockDB_Migrate_Call) Run ¶
func (_c *MockDB_Migrate_Call) Run(run func(ctx context.Context)) *MockDB_Migrate_Call
func (*MockDB_Migrate_Call) RunAndReturn ¶
func (_c *MockDB_Migrate_Call) RunAndReturn(run func(context.Context) error) *MockDB_Migrate_Call
type MockDB_UpdateFile_Call ¶
MockDB_UpdateFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateFile'
func (*MockDB_UpdateFile_Call) Return ¶
func (_c *MockDB_UpdateFile_Call) Return(_a0 error) *MockDB_UpdateFile_Call
func (*MockDB_UpdateFile_Call) Run ¶
func (_c *MockDB_UpdateFile_Call) Run(run func(ctx context.Context, file *snips.File)) *MockDB_UpdateFile_Call
func (*MockDB_UpdateFile_Call) RunAndReturn ¶
func (_c *MockDB_UpdateFile_Call) RunAndReturn(run func(context.Context, *snips.File) error) *MockDB_UpdateFile_Call