mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-05 01:38:51 +01:00
Merge a60a9e6642 into caa2f8a0c0
This commit is contained in:
commit
38960501fd
91 changed files with 7115 additions and 157 deletions
|
|
@ -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
8
tests/mock_grant_repo.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue