Large manual tests corruption fix
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user