diff --git a/.mockery.yaml b/.mockery.yaml index db2c076..c57e27a 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -1,6 +1,7 @@ with-expecter: True dir: mocks/ outpkg: mocks +issue-845-fix: True packages: me-fit/service: interfaces: diff --git a/Dockerfile b/Dockerfile index 80a0a11..4db9014 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM golang:1.23.3@sha256:73f06be4578c9987ce560087e2e2ea6485fb605e3910542cadd8fa09fc5f3e31 AS builder_go WORKDIR /me-fit -RUN go install github.com/a-h/templ/cmd/templ@latest && go install github.com/vektra/mockery/v2@latest +RUN go install github.com/a-h/templ/cmd/templ@latest && go install github.com/vektra/mockery/v2@latest && go install honnef.co/go/tools/cmd/staticcheck@latest COPY go.mod go.sum ./ RUN go mod download COPY . ./ -RUN templ generate && mockery && go test ./... && go build -o /me-fit/me-fit . +RUN templ generate && mockery --log-level warn && staticcheck ./... && go test ./... && go build -o /me-fit/me-fit . FROM node:22.11.0@sha256:5c76d05034644fa8ecc9c2aa84e0a83cd981d0ef13af5455b87b9adf5b216561 AS builder_node diff --git a/handler/index_and_404.go b/handler/index_and_404.go index 796bdcb..57e2229 100644 --- a/handler/index_and_404.go +++ b/handler/index_and_404.go @@ -36,7 +36,7 @@ func (handler IndexHandlerImpl) handle(router *http.ServeMux) { func (handler IndexHandlerImpl) handleIndexAnd404() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - user, err := handler.service.GetUserFromSessionId(utils.GetSessionID(r)) + user, _ := handler.service.GetUserFromSessionId(utils.GetSessionID(r)) var comp templ.Component = nil userComp := service.UserInfoComp(user) @@ -48,7 +48,7 @@ func (handler IndexHandlerImpl) handleIndexAnd404() http.HandlerFunc { comp = template.Layout(template.Index(), userComp, handler.serverSettings.Environment) } - err = comp.Render(r.Context(), w) + err := comp.Render(r.Context(), w) if err != nil { utils.LogError("Failed to render index", err) http.Error(w, "Failed to render index", http.StatusInternalServerError) diff --git a/service/auth.go b/service/auth.go index 8d7fc10..5137019 100644 --- a/service/auth.go +++ b/service/auth.go @@ -24,11 +24,11 @@ import ( ) var ( - ErrInvaidCredentials = errors.New("Invalid email or password") - ErrInvalidPassword = errors.New("Password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character") - ErrInvalidEmail = errors.New("Invalid email") - ErrAccountExists = errors.New("Account already exists") - ErrSessionIdInvalid = errors.New("Session ID is invalid") + ErrInvaidCredentials = errors.New("invalid email or password") + ErrInvalidPassword = errors.New("password needs to be 8 characters long, contain at least one number, one special, one uppercase and one lowercase character") + ErrInvalidEmail = errors.New("invalid email") + ErrAccountExists = errors.New("account already exists") + ErrSessionIdInvalid = errors.New("session ID is invalid") ) type User struct { diff --git a/service/workout.go b/service/workout.go index 97d0b1e..f8b6776 100644 --- a/service/workout.go +++ b/service/workout.go @@ -61,7 +61,7 @@ func NewWorkoutDto(rowId string, date string, workoutType string, sets string, r } var ( - ErrInputValues = errors.New("Invalid input values") + ErrInputValues = errors.New("invalid input values") ) func (service WorkoutServiceImpl) AddWorkout(user *User, workoutDto *WorkoutDto) (*WorkoutDto, error) { @@ -125,15 +125,6 @@ func (service WorkoutServiceImpl) GetWorkouts(user *User) ([]*WorkoutDto, error) return workoutsDto, nil } -func renderDateStr(date string) (string, error) { - t, err := time.Parse("2006-01-02 15:04:05-07:00", date) - if err != nil { - return "", err - } - - return renderDate(t), nil -} - func renderDate(date time.Time) string { return date.Format("2006-01-02") } diff --git a/types/types.go b/types/types.go index 7c1b413..c2c9acd 100644 --- a/types/types.go +++ b/types/types.go @@ -5,5 +5,5 @@ import ( ) var ( - ErrInternal = errors.New("Internal server error") + ErrInternal = errors.New("internal server error") )