On branch main
modified: main_dc/yalarba/api_yal/cmd/testrunner/main.go modified: main_dc/yalarba/api_yal/cmd/testrunner/runner.go modified: main_dc/yalarba/api_yal/tests/integration/account_test.go modified: main_dc/yalarba/api_yal/tests/integration/appeal_test.go modified: main_dc/yalarba/api_yal/tests/integration/auth_test.go modified: main_dc/yalarba/api_yal/tests/integration/comment_test.go modified: main_dc/yalarba/api_yal/tests/integration/feedback_test.go modified: main_dc/yalarba/api_yal/tests/integration/object_test.go modified: main_dc/yalarba/api_yal/tests/integration/rating_test.go deleted: main_dc/yalarba/api_yal/tests/testutils/client.go modified: main_dc/yalarba/api_yal/tests/testutils/fixtures.go modified: main_dc/yalarba/api_yal/tests/testutils/setup.go write comments for and into test's functions
This commit is contained in:
@@ -5,9 +5,12 @@ import (
|
||||
"api_yal/tests/testutils"
|
||||
)
|
||||
|
||||
// TestCommentEndpoints тестирует все эндпоинты для работы с комментариями к отзывам
|
||||
// Включает создание, получение, обновление, удаление комментариев и получение статистики
|
||||
func TestCommentEndpoints(t *testing.T) {
|
||||
config := testutils.NewTestConfig()
|
||||
|
||||
// CreateComment тестирует создание нового комментария к отзыву
|
||||
t.Run("CreateComment", func(t *testing.T) {
|
||||
user := config.CreateTestUser(t)
|
||||
defer config.CleanupTestUser(t, user)
|
||||
@@ -40,6 +43,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// GetCommentByID тестирует получение комментария по ID
|
||||
t.Run("GetCommentByID", func(t *testing.T) {
|
||||
user := config.CreateTestUser(t)
|
||||
defer config.CleanupTestUser(t, user)
|
||||
@@ -65,6 +69,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
|
||||
commentID := createdComment["id"].(float64)
|
||||
|
||||
// Получение комментария доступно без авторизации
|
||||
getResp, err := config.Request("GET", "/comments/"+string(rune(commentID)), nil, "")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get comment: %v", err)
|
||||
@@ -76,6 +81,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// UpdateComment тестирует обновление текста комментария автором
|
||||
t.Run("UpdateComment", func(t *testing.T) {
|
||||
user := config.CreateTestUser(t)
|
||||
defer config.CleanupTestUser(t, user)
|
||||
@@ -116,6 +122,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// ListComments тестирует получение списка комментариев с пагинацией
|
||||
t.Run("ListComments", func(t *testing.T) {
|
||||
resp, err := config.Request("GET", "/comments?page=1&page_size=20", nil, "")
|
||||
if err != nil {
|
||||
@@ -128,6 +135,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// MyComments тестирует получение комментариев текущего пользователя
|
||||
t.Run("MyComments", func(t *testing.T) {
|
||||
user := config.CreateTestUser(t)
|
||||
defer config.CleanupTestUser(t, user)
|
||||
@@ -143,6 +151,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// CommentsByFeedback тестирует получение комментариев для конкретного отзыва
|
||||
t.Run("CommentsByFeedback", func(t *testing.T) {
|
||||
user := config.CreateTestUser(t)
|
||||
defer config.CleanupTestUser(t, user)
|
||||
@@ -161,6 +170,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// CommentStats тестирует получение статистики по комментариям
|
||||
t.Run("CommentStats", func(t *testing.T) {
|
||||
resp, err := config.Request("GET", "/comments/stats", nil, "")
|
||||
if err != nil {
|
||||
@@ -177,6 +187,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
t.Fatalf("Failed to parse response: %v", err)
|
||||
}
|
||||
|
||||
// Проверяем наличие полей статистики
|
||||
expectedFields := []string{"total_comments", "verified_comments", "unverified_comments"}
|
||||
for _, field := range expectedFields {
|
||||
if _, ok := stats[field]; !ok {
|
||||
@@ -185,6 +196,7 @@ func TestCommentEndpoints(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// DeleteComment тестирует удаление комментария автором
|
||||
t.Run("DeleteComment", func(t *testing.T) {
|
||||
user := config.CreateTestUser(t)
|
||||
defer config.CleanupTestUser(t, user)
|
||||
|
||||
Reference in New Issue
Block a user