Implemented nowplaying repo
This commit is contained in:
@@ -11,8 +11,9 @@ func CreateMockNowPlayingRepo() *MockNowPlaying {
|
||||
|
||||
type MockNowPlaying struct {
|
||||
NowPlayingRepository
|
||||
data map[string]time.Time
|
||||
err bool
|
||||
id string
|
||||
start time.Time
|
||||
err bool
|
||||
}
|
||||
|
||||
func (m *MockNowPlaying) SetError(err bool) {
|
||||
@@ -23,6 +24,7 @@ func (m *MockNowPlaying) Add(id string) error {
|
||||
if m.err {
|
||||
return errors.New("Error!")
|
||||
}
|
||||
m.data[id] = time.Now()
|
||||
m.id = id
|
||||
m.start = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
+7
-2
@@ -11,10 +11,11 @@ import (
|
||||
|
||||
type Scrobbler interface {
|
||||
Register(id string, playDate time.Time) (*domain.MediaFile, error)
|
||||
NowPlaying(id string) (*domain.MediaFile, error)
|
||||
}
|
||||
|
||||
func NewScrobbler(itunes itunesbridge.ItunesControl, mr domain.MediaFileRepository, npr NowPlayingRepository) Scrobbler {
|
||||
return scrobbler{itunes, mr, npr}
|
||||
return &scrobbler{itunes, mr, npr}
|
||||
}
|
||||
|
||||
type scrobbler struct {
|
||||
@@ -23,7 +24,7 @@ type scrobbler struct {
|
||||
npRepo NowPlayingRepository
|
||||
}
|
||||
|
||||
func (s scrobbler) Register(id string, playDate time.Time) (*domain.MediaFile, error) {
|
||||
func (s *scrobbler) Register(id string, playDate time.Time) (*domain.MediaFile, error) {
|
||||
mf, err := s.mfRepo.Get(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -38,3 +39,7 @@ func (s scrobbler) Register(id string, playDate time.Time) (*domain.MediaFile, e
|
||||
}
|
||||
return mf, nil
|
||||
}
|
||||
|
||||
func (s *scrobbler) NowPlaying(id string) (*domain.MediaFile, error) {
|
||||
return nil, errors.New("Not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user