tercul-backend/repositories/work_repository_test.go
Damir Mukimov 4957117cb6 Initial commit: Tercul Go project with comprehensive architecture
- Core Go application with GraphQL API using gqlgen
- Comprehensive data models for literary works, authors, translations
- Repository pattern with caching layer
- Authentication and authorization system
- Linguistics analysis capabilities with multiple adapters
- Vector search integration with Weaviate
- Docker containerization support
- Python data migration and analysis scripts
- Clean architecture with proper separation of concerns
- Production-ready configuration and middleware
- Proper .gitignore excluding vendor/, database files, and build artifacts
2025-08-13 07:42:32 +02:00

55 lines
1.5 KiB
Go

package repositories_test
import (
"context"
"tercul/internal/testutil"
"tercul/models"
"testing"
"github.com/stretchr/testify/suite"
)
// WorkRepositorySuite is a test suite for the MockWorkRepository
type WorkRepositorySuite struct {
suite.Suite
repo *testutil.UnifiedMockWorkRepository
}
func (s *WorkRepositorySuite) SetupTest() {
s.repo = testutil.NewUnifiedMockWorkRepository()
}
func (s *WorkRepositorySuite) TestCreate() {
work := &models.Work{Title: "Test Work"}
err := s.repo.Create(context.Background(), work)
s.Require().NoError(err)
}
func (s *WorkRepositorySuite) TestGetByID() {
work := &models.Work{Title: "Test Work"}
s.repo.Create(context.Background(), work)
got, err := s.repo.GetByID(context.Background(), work.ID)
s.Require().NoError(err)
s.Require().Equal(work.ID, got.ID)
}
func (s *WorkRepositorySuite) TestFindByTitle() {
work := &models.Work{Title: "Test"}
s.repo.Create(context.Background(), work)
works, err := s.repo.FindByTitle(context.Background(), "Test")
s.Require().NoError(err)
s.Require().Len(works, 1)
}
func (s *WorkRepositorySuite) TestFindByLanguage() {
work := &models.Work{TranslatableModel: models.TranslatableModel{Language: "en"}, Title: "Test"}
s.repo.Create(context.Background(), work)
result, err := s.repo.FindByLanguage(context.Background(), "en", 1, 10)
s.Require().NoError(err)
s.Require().Len(result.Items, 1)
}
func TestWorkRepositorySuite(t *testing.T) {
suite.Run(t, new(WorkRepositorySuite))
}