mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-06 05:57:35 +03:00
New NowPlaying and Skip detection implementation
This commit is contained in:
parent
59a0ab3793
commit
c580a4199e
8 changed files with 127 additions and 91 deletions
|
@ -14,7 +14,7 @@ func CreateMockMediaFileRepo() *MockMediaFile {
|
|||
|
||||
type MockMediaFile struct {
|
||||
domain.MediaFileRepository
|
||||
data map[string]*domain.MediaFile
|
||||
data map[string]domain.MediaFile
|
||||
err bool
|
||||
}
|
||||
|
||||
|
@ -23,14 +23,14 @@ func (m *MockMediaFile) SetError(err bool) {
|
|||
}
|
||||
|
||||
func (m *MockMediaFile) SetData(j string, size int) {
|
||||
m.data = make(map[string]*domain.MediaFile)
|
||||
m.data = make(map[string]domain.MediaFile)
|
||||
var l = make(domain.MediaFiles, size)
|
||||
err := json.Unmarshal([]byte(j), &l)
|
||||
if err != nil {
|
||||
fmt.Println("ERROR: ", err)
|
||||
}
|
||||
for _, a := range l {
|
||||
m.data[a.Id] = &a
|
||||
m.data[a.Id] = a
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func (m *MockMediaFile) Get(id string) (*domain.MediaFile, error) {
|
|||
return nil, errors.New("Error!")
|
||||
}
|
||||
if d, ok := m.data[id]; ok {
|
||||
return d, nil
|
||||
return &d, nil
|
||||
}
|
||||
return nil, domain.ErrNotFound
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func (m *MockMediaFile) FindByAlbum(artistId string) (domain.MediaFiles, error)
|
|||
i := 0
|
||||
for _, a := range m.data {
|
||||
if a.AlbumId == artistId {
|
||||
res[i] = *a
|
||||
res[i] = a
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue