mocks

package
v0.0.0-...-4877560 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExampleUserToken = entities.UserToken{
		ID:        "609bba6ffc79f3b3bdd9431f",
		UserID:    UserID,
		Token:     "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYwNzJkMzIwNjE0NDY0NDk4NGE1NGZhMSIsImNyZWF0ZWRBdCI6MTYyMDQ4Njg2MjkyOTA2NTUwMCwiciI6eyJ0b2tlbiI6IjRiYmI1NDZlLTM0MjEtNGI1Ni1iODI2LWQwYjY0OGM3YjUzYiJ9LCJleHAiOjE2MjA0ODcxNjIsImlhdCI6MTYyMDQ4Njg2Mn0.j8dSyoCoSiKOI1duK9eNAl2LFgHjV0fe8eB58IhxlvI",
		Device:    "PostmanRuntime/7.26.10",
		CreatedAt: Now,
		ExpiresAt: Now.AddDate(1, 0, 0),
	}
	ExampleRefreshToken = entities.RefreshToken{
		ID:        "609bba6ffc79f3b3bdd9431e",
		UserID:    UserID,
		Token:     "4bbb546e-3421-4b56-b826-d0b648c7b53b",
		CreatedAt: Now,
		ExpiresAt: Now.AddDate(1, 0, 0),
	}

	ExampleResetPwdReq = entities.ResetPwdReq{
		ID:           "609ba7fedcc11ebd3051a816",
		EmailAddress: ExampleUser.EmailAddress,
		Status:       entities.ResetPwdStatusNoActionYet,
		ExpiresAt:    Now.Add(time.Minute * 15),
		CreatedAt:    Now,
	}
)
View Source
var (
	UserID            = "6072d3206144644984a54fa1"
	NonexistingUserID = UserID[:len(UserID)-1] + "a"

	NonexistingEmail = "notfound@example.com"
	Password         = []byte("TheSecretestPasswordEver123$%^")
	PasswordHash     = []byte("$2a$04$d0sgKcu9y.h8grIpktLj9OAdcv7pGy5CZ9aaz5zqPAkPyqlxLGF5W")

	Now = time.Now().UTC()
)
View Source
var (
	ExampleTraining = entities.Training{
		ID:        "607443ceb40d9ea8602803e7",
		UserID:    UserID,
		StartTime: Now.Add(-2 * time.Hour),
		Exercises: []entities.TrainingExercise{
			{
				ID:         "607400d5bf81935a539bd698",
				ExerciseID: ExampleExercise.ID,
				StartTime:  Now.Add(-115 * time.Minute),
				EndTime:    Now,
				Sets: []entities.TrainingSet{
					{
						ID:   "60740f289ee8e963adb5412a",
						Time: Now.Add(-110 * time.Minute),
						Reps: 12,
					},
					{
						ID:   "60740f289ee8e963adb5412d",
						Time: Now.Add(-107 * time.Minute),
						Reps: 10,
					},
					{
						ID:   "60740f289ee8e963adb5412c",
						Time: Now.Add(-103 * time.Minute),
						Reps: 10,
					},
				},
				Comment: "too short breaks",
			},
			{
				ID:         "60740f289ee8e963adb5412b",
				ExerciseID: ExampleExercise.ID,
				StartTime:  Now.Add(-115 * time.Minute),
			},
		},

		Comment: "too long, too heavy",
	}

	ExampleTrainingExercise = ExampleTraining.Exercises[0]
	ExampleTrainingSet      = ExampleTrainingExercise.Sets[0]
)
View Source
var ExampleExercise = entities.Exercise{
	ID:          "6072d3206144644984a54fa0",
	Name:        "Deadlift",
	Description: "The deadlift is an exercise in which a loaded bar is lifted off the ground to the level of the hips.",
	SetUnit:     entities.Weight,
	CreatedAt:   Now,
	CreatedBy:   UserID,
}
View Source
var (
	ExampleUser = entities.User{
		ID:           UserID,
		Username:     "John Silver",
		EmailAddress: "johnsilver@email.com",
		CreatedAt:    Now,
	}
)

Functions

func InsertMockExercise

func InsertMockExercise(er usecases.ExerciseRepo) (*entities.Exercise, error)

func InsertMockUser

func InsertMockUser(ur usecases.UserRepo) (*entities.User, error)

InsertMockUser inserts mocked user to repository with use of the repo functionality

func StartMockTraining

func StartMockTraining(tr usecases.TrainingRepo) (*entities.Training, error)

Types

type MockAuthRepo

type MockAuthRepo struct{}

func (*MockAuthRepo) AddResetPasswordRequest

func (r *MockAuthRepo) AddResetPasswordRequest(
	ctx context.Context,
	emailaddress string,
	expiresAt time.Time) (*entities.ResetPwdReq, error)

func (*MockAuthRepo) ChangePassword

func (r *MockAuthRepo) ChangePassword(
	ctx context.Context,
	userID string,
	newPwd []byte) error

func (*MockAuthRepo) DeleteJWT

func (r *MockAuthRepo) DeleteJWT(
	ctx context.Context,
	token *entities.UserToken) (int64, error)

func (*MockAuthRepo) DeleteRefreshToken

func (r *MockAuthRepo) DeleteRefreshToken(
	ctx context.Context,
	userID string) (n int64, err error)

func (*MockAuthRepo) DeleteRefreshTokenAndAllTokens

func (r *MockAuthRepo) DeleteRefreshTokenAndAllTokens(
	ctx context.Context,
	userID string) (n int64, err error)

func (*MockAuthRepo) GetRefreshToken

func (r *MockAuthRepo) GetRefreshToken(
	ctx context.Context,
	userID string) (*entities.RefreshToken, error)

func (*MockAuthRepo) GetUserByEmailAddress

func (r *MockAuthRepo) GetUserByEmailAddress(
	ctx context.Context,
	emailAddress string) (*entities.AuthUser, error)

func (*MockAuthRepo) GetUserByID

func (r *MockAuthRepo) GetUserByID(ctx context.Context, id string) (*entities.AuthUser, error)

func (*MockAuthRepo) GetUserJWTs

func (r *MockAuthRepo) GetUserJWTs(
	ctx context.Context,
	userID string,
	expired entities.ExpireType,
) ([]entities.UserToken, error)

func (*MockAuthRepo) SaveJWT

func (r *MockAuthRepo) SaveJWT(
	ctx context.Context,
	userID string,
	device string,
	token string,
	expiresAt time.Time) (*entities.UserToken, error)

func (*MockAuthRepo) SaveRefreshToken

func (r *MockAuthRepo) SaveRefreshToken(
	ctx context.Context,
	userID string,
	token string,
	expiresAt time.Time) (*entities.RefreshToken, error)

func (*MockAuthRepo) UpdatePasswordForResetRequest

func (r *MockAuthRepo) UpdatePasswordForResetRequest(
	ctx context.Context,
	reqID string,
	pwdHash []byte) error

type MockExerciseRepo

type MockExerciseRepo struct{}

func (*MockExerciseRepo) CreateExercise

func (er *MockExerciseRepo) CreateExercise(
	ctx context.Context,
	name string,
	description string,
	setUnit entities.SetUnit,
	createdBy string) (*entities.Exercise, error)

func (*MockExerciseRepo) GetExerciseByID

func (er *MockExerciseRepo) GetExerciseByID(
	ctx context.Context,
	id string) (*entities.Exercise, error)

func (*MockExerciseRepo) GetExercisesByName

func (er *MockExerciseRepo) GetExercisesByName(
	ctx context.Context,
	name string) ([]entities.Exercise, error)

func (*MockExerciseRepo) UpdateExercise

func (er *MockExerciseRepo) UpdateExercise(
	ctx context.Context,
	ex *entities.Exercise) (*entities.Exercise, error)

type MockMailer

type MockMailer struct{}

func (*MockMailer) Close

func (m *MockMailer) Close()

func (*MockMailer) Send

func (m *MockMailer) Send(recipients []string, subject, data []byte)

type MockTrainingRepo

type MockTrainingRepo struct {
}

func (*MockTrainingRepo) AddSet

func (tr *MockTrainingRepo) AddSet(
	ctx context.Context,
	userID, teID string,
	set *entities.TrainingSet) (*entities.TrainingSet, error)

func (*MockTrainingRepo) EndExercise

func (tr *MockTrainingRepo) EndExercise(
	ctx context.Context,
	userID, id string,
	endTime time.Time) (*entities.TrainingExercise, error)

func (*MockTrainingRepo) EndTraining

func (tr *MockTrainingRepo) EndTraining(
	ctx context.Context,
	id string,
	endTime time.Time) (*entities.Training, error)

func (*MockTrainingRepo) GetTrainingByID

func (tr *MockTrainingRepo) GetTrainingByID(
	ctx context.Context,
	id string) (*entities.Training, error)

func (*MockTrainingRepo) GetTrainingExercises

func (tr *MockTrainingRepo) GetTrainingExercises(
	ctx context.Context,
	id string) ([]entities.TrainingExercise, error)

func (*MockTrainingRepo) GetUserTrainings

func (tr *MockTrainingRepo) GetUserTrainings(
	ctx context.Context,
	userID string,
	started bool) ([]entities.Training, error)

func (*MockTrainingRepo) StartExercise

func (tr *MockTrainingRepo) StartExercise(
	ctx context.Context,
	trID string,
	exercise *entities.TrainingExercise) (*entities.TrainingExercise, error)

func (*MockTrainingRepo) StartTraining

func (tr *MockTrainingRepo) StartTraining(
	ctx context.Context,
	userID string,
	startTime time.Time) (*entities.Training, error)

type MockUserRepo

type MockUserRepo struct {
}

func (MockUserRepo) CreateUser

func (ur MockUserRepo) CreateUser(
	ctx context.Context,
	username, email string, passwordHash []byte) (*entities.User, error)

func (MockUserRepo) GetUserByID

func (ur MockUserRepo) GetUserByID(
	ctx context.Context,
	id string) (*entities.User, error)

Jump to

Keyboard shortcuts

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