diff --git a/persistence/playlist_repository_test.go b/persistence/playlist_repository_test.go index a84e4b044..05a36352f 100644 --- a/persistence/playlist_repository_test.go +++ b/persistence/playlist_repository_test.go @@ -372,15 +372,18 @@ var _ = Describe("PlaylistRepository", func() { var testPlaylistID string var lib2ID int var restrictedUserID string + var uniqueLibPath string BeforeEach(func() { db := GetDBXBuilder() // Generate unique IDs for this test run - restrictedUserID = "restricted-user-" + time.Now().Format("20060102150405.000") + uniqueSuffix := time.Now().Format("20060102150405.000") + restrictedUserID = "restricted-user-" + uniqueSuffix + uniqueLibPath = "/music/lib2-" + uniqueSuffix - // Create a second library - _, err := db.DB().Exec("INSERT INTO library (name, path, created_at, updated_at) VALUES ('Library 2', '/music/lib2', datetime('now'), datetime('now'))") + // Create a second library with unique name and path to avoid conflicts with other tests + _, err := db.DB().Exec("INSERT INTO library (name, path, created_at, updated_at) VALUES (?, ?, datetime('now'), datetime('now'))", "Library 2-"+uniqueSuffix, uniqueLibPath) Expect(err).ToNot(HaveOccurred()) err = db.DB().QueryRow("SELECT last_insert_rowid()").Scan(&lib2ID) Expect(err).ToNot(HaveOccurred()) @@ -420,7 +423,7 @@ var _ = Describe("PlaylistRepository", func() { ArtistID: "1", Album: "Test Album", AlbumID: "101", - Path: "/music/lib2/song.mp3", + Path: uniqueLibPath + "/song.mp3", LibraryID: lib2ID, Participants: model.Participants{}, Tags: model.Tags{}, diff --git a/persistence/tag_library_filtering_test.go b/persistence/tag_library_filtering_test.go index ab0d57d52..77b91847a 100644 --- a/persistence/tag_library_filtering_test.go +++ b/persistence/tag_library_filtering_test.go @@ -2,6 +2,7 @@ package persistence import ( "context" + "time" "github.com/deluan/rest" "github.com/navidrome/navidrome/conf/configtest" @@ -45,6 +46,9 @@ var _ = Describe("Tag Library Filtering", func() { BeforeEach(func() { DeferCleanup(configtest.SetupConfig()) + // Generate unique path suffix to avoid conflicts with other tests + uniqueSuffix := time.Now().Format("20060102150405.000") + // Clean up database db := GetDBXBuilder() _, err := db.NewQuery("DELETE FROM library_tag").Execute() @@ -57,12 +61,12 @@ var _ = Describe("Tag Library Filtering", func() { _, err = db.NewQuery("DELETE FROM library WHERE id > 1").Execute() Expect(err).ToNot(HaveOccurred()) - // Create test libraries + // Create test libraries with unique names and paths to avoid conflicts with other tests _, err = db.NewQuery("INSERT INTO library (id, name, path) VALUES ({:id}, {:name}, {:path})"). - Bind(dbx.Params{"id": libraryID2, "name": "Library 2", "path": "/music/lib2"}).Execute() + Bind(dbx.Params{"id": libraryID2, "name": "Library 2-" + uniqueSuffix, "path": "/music/lib2-" + uniqueSuffix}).Execute() Expect(err).ToNot(HaveOccurred()) _, err = db.NewQuery("INSERT INTO library (id, name, path) VALUES ({:id}, {:name}, {:path})"). - Bind(dbx.Params{"id": libraryID3, "name": "Library 3", "path": "/music/lib3"}).Execute() + Bind(dbx.Params{"id": libraryID3, "name": "Library 3-" + uniqueSuffix, "path": "/music/lib3-" + uniqueSuffix}).Execute() Expect(err).ToNot(HaveOccurred()) // Give admin access to all libraries