tercul-backend/internal/testutil/simple_test_utils.go
Damir Mukimov fa336cacf3
wip
2025-09-01 00:43:59 +02:00

53 lines
1.3 KiB
Go

package testutil
import (
"tercul/graph"
"tercul/internal/models"
"tercul/services"
"github.com/stretchr/testify/suite"
)
// SimpleTestSuite provides a minimal test environment with just the essentials
type SimpleTestSuite struct {
suite.Suite
WorkRepo *UnifiedMockWorkRepository
WorkService services.WorkService
}
// SetupSuite sets up the test suite
func (s *SimpleTestSuite) SetupSuite() {
s.WorkRepo = NewUnifiedMockWorkRepository()
s.WorkService = services.NewWorkService(s.WorkRepo, nil)
}
// SetupTest resets test data for each test
func (s *SimpleTestSuite) SetupTest() {
s.WorkRepo.Reset()
}
// GetResolver returns a minimal GraphQL resolver for testing
func (s *SimpleTestSuite) GetResolver() *graph.Resolver {
return &graph.Resolver{
WorkRepo: s.WorkRepo,
WorkService: s.WorkService,
// Other fields will be nil, but that's okay for basic tests
}
}
// CreateTestWork creates a test work with optional content
func (s *SimpleTestSuite) CreateTestWork(title, language string, content string) *models.Work {
work := &models.Work{
Title: title,
}
work.Language = language
// Add work to the mock repository
s.WorkRepo.AddWork(work)
// If content is provided, we'll need to handle it differently
// since the mock repository doesn't support translations yet
// For now, just return the work
return work
}