users

package
v0.0.0-...-721515e Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound represent a not found error.

Functions

func NewMongoDB

func NewMongoDB() (*mongoDB, error)

NewMongoDB creates a new article repository backed by a given Mongo server, authenticated with given credentials.

Types

type MockRepository

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

MockRepository is a mock of Repository interface It's generated by go mock by invoking this command: mockgen -source=srv.go See more at: https://github.com/golang/mock

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance

func (*MockRepository) AddUser

func (_m *MockRepository) AddUser(u User) error

AddUser mocks base method

func (*MockRepository) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRepository) GetUsers

func (_m *MockRepository) GetUsers() ([]*User, error)

GetUsers mocks base method

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository

func (*MockRepositoryMockRecorder) AddUser

func (_mr *MockRepositoryMockRecorder) AddUser(arg0 interface{}) *gomock.Call

AddUser indicates an expected call of AddUser

func (*MockRepositoryMockRecorder) GetUsers

func (_mr *MockRepositoryMockRecorder) GetUsers() *gomock.Call

GetUsers indicates an expected call of GetUsers

type Repository

type Repository interface {
	GetUsers() ([]*User, error)
	AddUser(u User) error
}

Repository user data store.

type User

type User struct {
	Name string
	Age  int
}

User hold user information.

type UserService

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

UserService hold all operations related to user.

func New

func New() *UserService

New create a new/empty user service

func (*UserService) AddUser

func (s *UserService) AddUser(u User) error

AddUser add a new user

func (*UserService) GetUsers

func (s *UserService) GetUsers() ([]*User, error)

GetUsers return list of users. return error if no user found.

func (*UserService) SetRepo

func (s *UserService) SetRepo(r Repository)

SetRepo set the repository to UserService for querying db

Jump to

Keyboard shortcuts

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