mock

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package mock implements storage interfaces that can be used in unit tests or for running long-season with volatile data storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory returns mock interfaces specific to stored data. Implements storage.Factory interface.

func New

func New() *Factory

New returns new mock factory.

func (Factory) Users

func (f Factory) Users() *UsersStorage

Users returns storage interface for manipulating users data.

type UsersStorage

type UsersStorage struct {
	// contains filtered or unexported fields
}

UsersStorage implements storage.Users interface for mocking purposes.

func (*UsersStorage) All

func (s *UsersStorage) All(ctx context.Context) ([]models.User, error)

All returns slice with all users from storage.

func (*UsersStorage) New

func (s *UsersStorage) New(ctx context.Context, newUser models.User) (string, error)

New stores given user data in database and returns assigned id.

func (*UsersStorage) Read

func (s *UsersStorage) Read(ctx context.Context, id string) (*models.User, error)

Read returns single user data with given ID.

func (*UsersStorage) Remove

func (s *UsersStorage) Remove(ctx context.Context, id string) error

Remove deletes user with given id from storage.

func (*UsersStorage) Update

func (s *UsersStorage) Update(ctx context.Context, u models.User) error

Update overwrites existing user data.

func (*UsersStorage) UpdateMany

func (s *UsersStorage) UpdateMany(ctx context.Context, u []models.User) error

UpdateMany overwrites data of all users in given slice.

Jump to

Keyboard shortcuts

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