test: align title validation errors with json tags

This commit is contained in:
2026-01-12 22:49:30 +01:00
parent e5779183ff
commit 5f605e45c7

View File

@@ -10,14 +10,15 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/go-chi/chi/v5"
"github.com/jackc/pgconn"
"gorm.io/gorm"
"goyco/internal/database" "goyco/internal/database"
"goyco/internal/middleware" "goyco/internal/middleware"
"goyco/internal/repositories" "goyco/internal/repositories"
"goyco/internal/services" "goyco/internal/services"
"goyco/internal/testutils" "goyco/internal/testutils"
"github.com/go-chi/chi/v5"
"github.com/jackc/pgconn"
"gorm.io/gorm"
) )
func decodeHandlerResponse(t *testing.T, rr *httptest.ResponseRecorder) map[string]any { func decodeHandlerResponse(t *testing.T, rr *httptest.ResponseRecorder) map[string]any {
@@ -466,7 +467,7 @@ func TestPostHandlerUpdatePost(t *testing.T) {
} }
}, },
expectedStatus: http.StatusBadRequest, expectedStatus: http.StatusBadRequest,
expectedError: "Title is required", expectedError: "title is required",
}, },
{ {
name: "short title", name: "short title",
@@ -480,7 +481,7 @@ func TestPostHandlerUpdatePost(t *testing.T) {
} }
}, },
expectedStatus: http.StatusBadRequest, expectedStatus: http.StatusBadRequest,
expectedError: "Title must be at least 3 characters", expectedError: "title must be at least 3 characters",
}, },
} }