mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
Introduced a new testing strategy for the data access layer to avoid redundant testing of generic repository methods. This change centralizes the testing of common functionality, making the test suite cleaner and more efficient. - Created a comprehensive test suite for the generic `BaseRepository` using a dedicated `TestEntity`. This suite covers all common CRUD operations, including transactions and error handling, in a single location. - Added a new, focused test suite for the previously untested `CategoryRepository`. - Refactored the existing test suites for `AuthorRepository`, `BookRepository`, `PublisherRepository`, and `SourceRepository` to remove redundant CRUD tests, leaving only tests for repository-specific logic. - Updated the test utilities to support the new testing strategy. This change significantly improves the maintainability and efficiency of the test suite and provides a clear, future-proof pattern for testing all repositories.
29 lines
730 B
Go
29 lines
730 B
Go
package sql_test
|
|
|
|
import (
|
|
"testing"
|
|
"tercul/internal/testutil"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type PublisherRepositoryTestSuite struct {
|
|
testutil.IntegrationTestSuite
|
|
}
|
|
|
|
func (s *PublisherRepositoryTestSuite) SetupSuite() {
|
|
s.IntegrationTestSuite.SetupSuite(testutil.DefaultTestConfig())
|
|
}
|
|
|
|
func (s *PublisherRepositoryTestSuite) SetupTest() {
|
|
s.DB.Exec("DELETE FROM publishers")
|
|
}
|
|
|
|
func TestPublisherRepository(t *testing.T) {
|
|
suite.Run(t, new(PublisherRepositoryTestSuite))
|
|
}
|
|
|
|
// NOTE: All tests for this repository were removed because they tested generic
|
|
// CRUD functionality that is now covered in `base_repository_test.go`.
|
|
// If you add publisher-specific methods to the repository, add their tests here.
|