From a82d3c69b147c9798a1be7f7a80c6a98554b241b Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 5 Apr 2025 16:52:41 +0300 Subject: . --- internal/handlers/handlers_test.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index 4eef3b9..2b3e667 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -1,36 +1,39 @@ package handlers import ( - "fmt" + "database/sql" + "demoon/config" + "demoon/internal/models" + "log/slog" + "net/http" + "net/http/httptest" "testing" - "github.com/playwright-community/playwright-go" "github.com/stretchr/testify/assert" ) - func TestGetQuestionHandler(t *testing.T) { t.Run("get existing question", func(t *testing.T) { // Setup mock repository mockRepo := &MockRepo{} handlers := NewHandlers(config.Config{}, slog.Default(), mockRepo) - + // Test request/response req := httptest.NewRequest("GET", "/question/1", nil) w := httptest.NewRecorder() - + // Call handler directly - handlers.GetQuestion(w, req) - + GetQuestion(w, req) + // Verify response resp := w.Result() assert.Equal(t, http.StatusOK, resp.StatusCode) - + // Add more assertions about response body }) } -type MockRepo struct{ +type MockRepo struct { questions map[uint32]*models.Question } -- cgit v1.2.3