test

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepository

func NewRepository(canQuery bool) *repository.Repository

NewRepository returns a Repository which persists users in memory and accepts a parameter that can trigger read/write errors

func NewSessionRepository

func NewSessionRepository(canQuery bool) repository.SessionRepository

NewSessionRepository returns pointer to repo along with the db

func NewUserRepository

func NewUserRepository(canQuery bool) repository.UserRepository

NewUserRepository will return errors

Types

type SessionRepository

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

SessionRepository uses gorm.DB for querying the database

func (*SessionRepository) CreateSession

func (repo *SessionRepository) CreateSession(session *models.Session) (*models.Session, error)

CreateSession must take in Key, Data, and ExpiresAt as arguments.

func (*SessionRepository) DeleteSession

func (repo *SessionRepository) DeleteSession(session *models.Session) (*models.Session, error)

DeleteSession deletes a session by Key

func (*SessionRepository) SelectSession

func (repo *SessionRepository) SelectSession(session *models.Session) (*models.Session, error)

SelectSession returns a session with matching key

func (*SessionRepository) UpdateSession

func (repo *SessionRepository) UpdateSession(session *models.Session) (*models.Session, error)

UpdateSession updates only the Data field using Key as selector.

type UserRepository

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

UserRepository will return errors on queries if canQuery is false and only stores a small set of users in-memory that are indexed by their array index + 1

func (*UserRepository) CheckPassword

func (repo *UserRepository) CheckPassword(id int, pwd string) (bool, error)

CheckPassword checks the input password is correct for the provided user id.

func (*UserRepository) CreateUser

func (repo *UserRepository) CreateUser(user *models.User) (*models.User, error)

CreateUser adds a new User row to the Users table in array memory

func (*UserRepository) DeleteUser

func (repo *UserRepository) DeleteUser(user *models.User) (*models.User, error)

DeleteUser deletes a single user using their unique id

func (*UserRepository) ReadUser

func (repo *UserRepository) ReadUser(id uint) (*models.User, error)

ReadUser finds a single user based on their unique id

func (*UserRepository) ReadUserByEmail

func (repo *UserRepository) ReadUserByEmail(email string) (*models.User, error)

ReadUserByEmail finds a single user based on their unique email

func (*UserRepository) UpdateUser

func (repo *UserRepository) UpdateUser(user *models.User) (*models.User, error)

UpdateUser modifies an existing User in the database

Jump to

Keyboard shortcuts

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