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)) }