This commit is contained in:
Deluan Quintão 2026-10-06 09:50:59 -04:00 • committed by GitHub
commit 38960501fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
91 changed files with 7115 additions and 157 deletions

View file

@ -30,6 +30,7 @@ type MockDataStore struct {
MockedPlugin model.PluginRepository
MockedArtwork model.ArtworkRepository
MockedArtworkQueue model.ArtworkQueueRepository
MockedGrant model.GrantRepository
scrobbleBufferMu sync.Mutex
repoMu sync.Mutex
@ -321,6 +322,19 @@ func (db *MockDataStore) ArtworkQueue() model.ArtworkQueueRepository {
return db.MockedArtworkQueue
}
func (db *MockDataStore) Grant() model.GrantRepository {
db.repoMu.Lock()
defer db.repoMu.Unlock()
if db.MockedGrant != nil {
return db.MockedGrant
}
if db.RealDS != nil {
return db.RealDS.Grant()
}
db.MockedGrant = &MockedGrantRepo{}
return db.MockedGrant
}
func (db *MockDataStore) WithTx(block func(tx model.DataStore) error, label ...string) error {
return block(db)
}

8
tests/mock_grant_repo.go Normal file
View file

@ -0,0 +1,8 @@
package tests
import "github.com/navidrome/navidrome/model"
// MockedGrantRepo exists so MockDataStore satisfies DataStore; auth tests use a real database.
type MockedGrantRepo struct {
model.GrantRepository
}