package handlers import ( "fmt" "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) // Verify response resp := w.Result() assert.Equal(t, http.StatusOK, resp.StatusCode) // Add more assertions about response body }) } type MockRepo struct{ questions map[uint32]*models.Question } func (m *MockRepo) DBGetQuestion(id string) (*models.Question, error) { if q, ok := m.questions[1]; ok { return q, nil } return nil, sql.ErrNoRows } func (m *MockRepo) DBGetDefaultsMap() (map[string]string, error) { return map[string]string{}, nil }