mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 21:17:37 +03:00
36 lines
629 B
Go
36 lines
629 B
Go
package engine
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
func CreateMockNowPlayingRepo() *MockNowPlaying {
|
|
return &MockNowPlaying{}
|
|
}
|
|
|
|
type MockNowPlaying struct {
|
|
NowPlayingRepository
|
|
info NowPlayingInfo
|
|
err bool
|
|
}
|
|
|
|
func (m *MockNowPlaying) SetError(err bool) {
|
|
m.err = err
|
|
}
|
|
|
|
func (m *MockNowPlaying) Set(id, username string, playerId int, playerName string) error {
|
|
if m.err {
|
|
return errors.New("Error!")
|
|
}
|
|
m.info.TrackId = id
|
|
m.info.Username = username
|
|
m.info.Start = time.Now()
|
|
m.info.PlayerId = playerId
|
|
m.info.PlayerName = playerName
|
|
return nil
|
|
}
|
|
|
|
func (m *MockNowPlaying) Current() NowPlayingInfo {
|
|
return m.info
|
|
}
|