New NowPlaying and Skip detection implementation

This commit is contained in:
Deluan 2016-03-23 10:06:26 -04:00
parent 59a0ab3793
commit c580a4199e
8 changed files with 127 additions and 91 deletions

View file

@ -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++
}
}