Started the implementation of getMusicDirectory. Probably will need to introduce a new 'service' layer...

This commit is contained in:
Deluan
2016-03-02 20:00:55 -05:00
parent 68786d4b39
commit 9577d9ae87
15 changed files with 166 additions and 16 deletions
+38
View File
@@ -0,0 +1,38 @@
package mocks
import (
"encoding/json"
"fmt"
"github.com/deluan/gosonic/domain"
"errors"
)
func CreateMockArtistRepo() *MockArtist {
return &MockArtist{}
}
type MockArtist struct {
domain.ArtistRepository
data map[string]domain.Artist
err bool
}
func (m *MockArtist) SetError(err bool) {
m.err = err
}
func (m *MockArtist) SetData(j string) {
m.data = make(map[string]domain.Artist)
err := json.Unmarshal([]byte(j), &m.data)
if err != nil {
fmt.Println("ERROR: ", err)
}
}
func (m *MockArtist) Exists(id string) (bool, error) {
if m.err {
return false, errors.New("Error!")
}
_, found := m.data[id];
return found, nil
}