Documentation ¶
Index ¶
- Variables
- type MockUserRepository
- func (m *MockUserRepository) Delete(ctx context.Context, id int) error
- func (m *MockUserRepository) GetByEmail(ctx context.Context, email string) (*User, error)
- func (m *MockUserRepository) GetByID(ctx context.Context, id int) (*User, error)
- func (m *MockUserRepository) GetUsers(ctx context.Context) ([]*User, error)
- func (m *MockUserRepository) Save(ctx context.Context, user *User) error
- func (m *MockUserRepository) Update(ctx context.Context, user *User) error
- type User
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUserNotFound = errors.New("user not found")
)
Functions ¶
This section is empty.
Types ¶
type MockUserRepository ¶
type MockUserRepository struct { GetUsersFunc func(ctx context.Context) ([]*User, error) GetByIDFunc func(ctx context.Context, id int) (*User, error) GetByEmailFunc func(ctx context.Context, email string) (*User, error) SaveFunc func(ctx context.Context, user *User) error DeleteFunc func(ctx context.Context, id int) error UpdateFunc func(ctx context.Context, user *User) error }
func (*MockUserRepository) Delete ¶
func (m *MockUserRepository) Delete(ctx context.Context, id int) error
func (*MockUserRepository) GetByEmail ¶
func (*MockUserRepository) GetUsers ¶
func (m *MockUserRepository) GetUsers(ctx context.Context) ([]*User, error)
type User ¶
type User struct { ID int FirstName string `json:"first_name,omitempty" validate:"required,min=2,max=100"` LastName string `json:"last_name,omitempty" validate:"required,min=2,max=100"` Email string `json:"email,omitempty" validate:"required,email"` Password string `json:"password,omitempty" validate:"required,min=8"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Role string `json:"role,omitempty" validate:"oneof=admin user"` Status string `json:"status,omitempty" validate:"oneof=active inactive"` }
type UserRepository ¶
type UserRepository interface { GetUsers(ctx context.Context) ([]*User, error) GetByID(ctx context.Context, id int) (*User, error) GetByEmail(ctx context.Context, email string) (*User, error) Save(ctx context.Context, user *User) error Delete(ctx context.Context, id int) error Update(ctx context.Context, user *User) error }
Click to show internal directories.
Click to hide internal directories.