Large manual tests corruption fix

This commit is contained in:
2026-03-02 18:07:13 +00:00
parent 817d5dd021
commit dd097c1022
14 changed files with 171 additions and 138 deletions
-1
View File
@@ -542,7 +542,6 @@ func ChangePasswordHandler(w http.ResponseWriter, r *http.Request) {
return
}
if req.NewPassword == req.CurrentPassword {
http.Error(w, "new password must be different from current password", http.StatusBadRequest)
return
+8 -15
View File
@@ -1,6 +1,8 @@
//go:build test
// +build test
package user
// Package user contains tests for user profile and account management endpoints.
//
// Test Coverage:
@@ -13,31 +15,24 @@
//
// Authentication: All endpoints require auth (401 for unauthenticated).
// Validation: Tests cover invalid inputs (missing fields, invalid phone, weak passwords).
package user
//go:build test
// +build test
package user
import (
"bytes"
"context"
"encoding/json"
"io"
"mime/multipart"
"net/http"
"net/http/httptest"
"testing"
"crussell/db"
"crussell/internal/s3"
"crussell/mw"
"crussell/testutils/fixtures"
"crussell/testutils/jwt"
"crussell/testutils/testdb"
"github.com/jackc/pgx/v5/pgxpool"
)
"bytes"
"context"
"encoding/json"
@@ -328,7 +323,6 @@ func TestLoyalty_Get(t *testing.T) {
}
}
// TestProfile_Update_InvalidInput verifies that profile update validation rejects invalid inputs:
// missing first name, missing last name, missing phone, invalid phone format, invalid characters in name, name too long.
func TestProfile_Update_InvalidInput(t *testing.T) {
@@ -343,9 +337,9 @@ func TestProfile_Update_InvalidInput(t *testing.T) {
token := jwt.GenerateUserToken(userID)
tests := []struct {
name string
req UpdateProfileRequest
expected int
name string
req UpdateProfileRequest
expected int
}{
{
name: "missing_first_name",
@@ -485,7 +479,6 @@ func TestPasswordChange_SameAsOld(t *testing.T) {
}
}
// TestProfile_UploadPicture verifies that a user can upload a profile picture. May return 500 if S3 is not configured.
func TestProfile_UploadPicture(t *testing.T) {
cleanup, pool := setupTest(t)
@@ -549,14 +542,14 @@ func TestProfile_UploadPicture(t *testing.T) {
req.Header.Set("Content-Type", writer.FormDataContentType())
rr := httptest.NewRecorder()
// Note: This test may return 500 if S3 is not configured
// In that case, we check for either success or proper error handling
if rr.Code != http.StatusOK && rr.Code != http.StatusInternalServerError {
t.Errorf("expected status 200 or 500 (if S3 not configured), got %d", rr.Code)
t.Logf("response body: %s", rr.Body.String())
}
// If S3 is configured, verify the response contains a URL
if rr.Code == http.StatusOK {
var resp map[string]string