Update CI configuration to use Go 1.24.1-alpine for build, lint, and test steps. Fix test database setup path in account tests and improve error handling in JWT verification.
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/tests Pipeline was successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
qpismont 2025-03-24 20:55:54 +00:00
parent a5e059a636
commit 9d544c7e8a
6 changed files with 12 additions and 8 deletions

View file

@ -3,7 +3,7 @@ when:
steps: steps:
- name: build - name: build
image: golang:1.24-alpine image: golang:1.24.1-alpine
commands: commands:
- apk update - apk update
- apk add bash - apk add bash

View file

@ -3,7 +3,7 @@ when:
steps: steps:
- name: lint - name: lint
image: golang:1.24-alpine image: golang:1.24.1-alpine
commands: commands:
- apk update - apk update
- apk add bash curl jq - apk add bash curl jq

View file

@ -3,7 +3,7 @@ when:
steps: steps:
- name: tests - name: tests
image: golang:1.24-alpine image: golang:1.24.1-alpine
environment: environment:
TEST_DB_HOST: db TEST_DB_HOST: db
TEST_DB_PORT: 5432 TEST_DB_PORT: 5432

View file

@ -9,7 +9,7 @@ import (
) )
func TestRepository_Insert(t *testing.T) { func TestRepository_Insert(t *testing.T) {
db := test.SetupTestDB(t, "../..") db := test.SetupTestDB(t, "../../..")
defer db.Close() defer db.Close()
repo := NewRepository(db) repo := NewRepository(db)
@ -29,7 +29,7 @@ func TestRepository_Insert(t *testing.T) {
} }
func TestRepository_FetchOneByUsername(t *testing.T) { func TestRepository_FetchOneByUsername(t *testing.T) {
db := test.SetupTestDB(t, "../..") db := test.SetupTestDB(t, "../../..")
defer db.Close() defer db.Close()
repo := NewRepository(db) repo := NewRepository(db)

View file

@ -32,6 +32,10 @@ func (s *Service) Login(login domain.AccountLogin) (*domain.AccountWithToken, *c
return nil, core.NewInternalServerError(err) return nil, core.NewInternalServerError(err)
} }
if account == nil {
return nil, domain.ErrAccountNotFound
}
ok, err := core.ComparePassword(login.Password, account.Password) ok, err := core.ComparePassword(login.Password, account.Password)
if err != nil { if err != nil {
return nil, domain.ErrBadPassword return nil, domain.ErrBadPassword

View file

@ -19,9 +19,9 @@ func TestJWT_GenerateToken(t *testing.T) {
assert.NotEmpty(t, token) assert.NotEmpty(t, token)
claims, err := VerifyJWT(token) claims, jwtErr := VerifyJWT(token)
if err != nil { if jwtErr != nil {
t.Fatalf("Failed to verify token: %v", err) t.Fatalf("Failed to verify token: %v", jwtErr)
} }
assert.Equal(t, claims.AccountId, 1) assert.Equal(t, claims.AccountId, 1)