mockstore

package
v0.0.0-...-2a11bd6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mockstore is used for testing purposes to mock the store package and mock a mysql db through a docker container of mysql

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropAndCreateAllTablesFor

func DropAndCreateAllTablesFor(db *gorm.DB) error

DropAndCreateAllTablesFor drops all tables in input db and recreates the ones listed in the function

func InsertRowsFor

func InsertRowsFor(db *gorm.DB, modelsList ...interface{}) error

InsertRowsFor inserts multiple values into database

func NewDataBaseConnection

func NewDataBaseConnection() (*gorm.DB, error)

NewDataBaseConnection creates and returns a new GORM connection to the test DB

Types

type UserDBClient

type UserDBClient struct {
	CreateFn         func(*gorm.DB, models.User) (*models.User, error)
	ViewFn           func(*gorm.DB, uint) (*models.User, error)
	FindByUsernameFn func(*gorm.DB, string) (*models.User, error)
	FindByTokenFn    func(*gorm.DB, string) (*models.User, error)
	ListFn           func(*gorm.DB, *models.ListQuery, *models.Pagination) ([]models.User, error)
	DeleteFn         func(*gorm.DB, *models.User) error
	UpdateFn         func(*gorm.DB, *models.User) error
}

UserDBClient database mock

func (*UserDBClient) Create

func (u *UserDBClient) Create(db *gorm.DB, usr models.User) (*models.User, error)

Create mock

func (*UserDBClient) Delete

func (u *UserDBClient) Delete(db *gorm.DB, usr *models.User) error

Delete mock

func (*UserDBClient) FindByToken

func (u *UserDBClient) FindByToken(db *gorm.DB, token string) (*models.User, error)

FindByToken mock

func (*UserDBClient) FindByUsername

func (u *UserDBClient) FindByUsername(db *gorm.DB, uname string) (*models.User, error)

FindByUsername mock

func (*UserDBClient) List

func (u *UserDBClient) List(db *gorm.DB, lq *models.ListQuery, p *models.Pagination) ([]models.User, error)

List mock

func (*UserDBClient) Update

func (u *UserDBClient) Update(db *gorm.DB, usr *models.User) error

Update mock

func (*UserDBClient) View

func (u *UserDBClient) View(db *gorm.DB, id uint) (*models.User, error)

View mock

Jump to

Keyboard shortcuts

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