mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 04:47:42 +03:00
Fixing NowPlaying when we have more than one song in the queue
This commit is contained in:
parent
c8184da0ed
commit
1a705d4319
@ -95,6 +95,21 @@ func TestSkipping(t *testing.T) {
|
||||
mfRepo.SetData(`[{"Id":"1","Title":"Femme Fatale"},{"Id":"2","Title":"Here She Comes Now"},{"Id":"3","Title":"Lady Godiva's Operation"}]`, 3)
|
||||
itCtrl.skipped = make(map[string]time.Time)
|
||||
npRepo.ClearAll()
|
||||
Convey("When I skip 2 songs", func() {
|
||||
start := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
|
||||
npRepo.OverrideNow(start)
|
||||
scrobbler.NowPlaying(1, "DSub", "1", "deluan")
|
||||
npRepo.OverrideNow(start.Add(time.Duration(2) * time.Second))
|
||||
scrobbler.NowPlaying(1, "DSub", "3", "deluan")
|
||||
npRepo.OverrideNow(start.Add(time.Duration(3) * time.Second))
|
||||
scrobbler.NowPlaying(1, "DSub", "2", "deluan")
|
||||
Convey("Then the NowPlaying song should be the last one", func() {
|
||||
np, err := npRepo.GetAll()
|
||||
So(err, ShouldBeNil)
|
||||
So(np, ShouldHaveLength, 1)
|
||||
So(np[0].TrackId, ShouldEqual, "2")
|
||||
})
|
||||
})
|
||||
Convey("When I play one song", func() {
|
||||
start := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
|
||||
npRepo.OverrideNow(start)
|
||||
|
@ -78,7 +78,7 @@ func (r *nowPlayingRepository) Count(playerId int) (int64, error) {
|
||||
|
||||
// TODO Will not work for multiple players
|
||||
func (r *nowPlayingRepository) GetAll() ([]*engine.NowPlayingInfo, error) {
|
||||
np, err := r.Tail(1)
|
||||
np, err := r.Head(1)
|
||||
if np == nil || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user