fix(tests): make collection names unique in bulk operations tests

- Fix TestCollectionsBulkOperations/BulkAddBooks_SingleOperation failure
- Each subtest was creating "Test Collection" with same name
- Collections table has UNIQUE(user_id, name) constraint causing 500 errors
- Made collection names unique by adding test name suffix:
  - Test Collection - InvalidBookID
  - Test Collection - SingleOperation
  - Test Collection - MultipleBooksSingleCollection
  - Test Collection 1 - MultipleCollections
  - Test Collection 2 - MultipleCollections
  - Test Collection - DuplicateBooks

This preserves test data for manual API testing with Bruno while
ensuring test isolation and preventing unique constraint violations.
This commit is contained in:
2026-02-11 10:56:47 -05:00
parent 891209b4bd
commit f93d44c5d1
+6 -6
View File
@@ -96,7 +96,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
t.Run("BulkAddBooks_InvalidBookID", func(t *testing.T) {
// Create a collection first
collectionReq := map[string]interface{}{
"name": "Test Collection",
"name": "Test Collection - InvalidBookID",
"description": "A test collection",
}
collectionBody, _ := json.Marshal(collectionReq)
@@ -145,7 +145,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
t.Run("BulkAddBooks_SingleOperation", func(t *testing.T) {
// Create a collection
collectionReq := map[string]interface{}{
"name": "Test Collection",
"name": "Test Collection - SingleOperation",
"description": "A test collection",
}
collectionBody, _ := json.Marshal(collectionReq)
@@ -202,7 +202,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
t.Run("BulkAddBooks_MultipleBooksSingleCollection", func(t *testing.T) {
// Create a collection
collectionReq := map[string]interface{}{
"name": "Test Collection",
"name": "Test Collection - MultipleBooksSingleCollection",
"description": "A test collection",
}
collectionBody, _ := json.Marshal(collectionReq)
@@ -255,7 +255,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
t.Run("BulkAddBooks_MultipleCollections", func(t *testing.T) {
// Create multiple collections
collectionReq := map[string]interface{}{
"name": "Test Collection 1",
"name": "Test Collection 1 - MultipleCollections",
"description": "First test collection",
}
collectionBody, _ := json.Marshal(collectionReq)
@@ -273,7 +273,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
collectionID1 := collectionResult1["id"].(string)
collectionReq2 := map[string]interface{}{
"name": "Test Collection 2",
"name": "Test Collection 2 - MultipleCollections",
"description": "Second test collection",
}
collectionBody2, _ := json.Marshal(collectionReq2)
@@ -329,7 +329,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
t.Run("BulkAddBooks_DuplicateBooks", func(t *testing.T) {
// Create a collection
collectionReq := map[string]interface{}{
"name": "Test Collection",
"name": "Test Collection - DuplicateBooks",
"description": "A test collection",
}
collectionBody, _ := json.Marshal(collectionReq)