More getMusicDirectory
This commit is contained in:
+6
-1
@@ -27,6 +27,12 @@ func ShouldMatchJSON(actual interface{}, expected ...interface{}) string {
|
||||
return ShouldEqual(s, expected[0].(string))
|
||||
}
|
||||
|
||||
func ShouldContainJSON(actual interface{}, expected ...interface{}) string {
|
||||
a := UnindentJSON(actual.(*bytes.Buffer).Bytes())
|
||||
|
||||
return ShouldContainSubstring(a, expected[0].(string))
|
||||
}
|
||||
|
||||
func ShouldReceiveError(actual interface{}, expected ...interface{}) string {
|
||||
v := responses.Subsonic{}
|
||||
err := xml.Unmarshal(actual.(*bytes.Buffer).Bytes(), &v)
|
||||
@@ -35,7 +41,6 @@ func ShouldReceiveError(actual interface{}, expected ...interface{}) string {
|
||||
}
|
||||
|
||||
return ShouldEqual(v.Error.Code, expected[0].(int))
|
||||
|
||||
}
|
||||
|
||||
func UnindentJSON(j []byte) string {
|
||||
|
||||
@@ -13,7 +13,7 @@ func CreateMockArtistRepo() *MockArtist {
|
||||
|
||||
type MockArtist struct {
|
||||
domain.ArtistRepository
|
||||
data map[string]domain.Artist
|
||||
data map[string]*domain.Artist
|
||||
err bool
|
||||
}
|
||||
|
||||
@@ -21,12 +21,16 @@ 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)
|
||||
func (m *MockArtist) SetData(j string, size int) {
|
||||
m.data = make(map[string]*domain.Artist)
|
||||
var l = make([]domain.Artist, size)
|
||||
err := json.Unmarshal([]byte(j), &l)
|
||||
if err != nil {
|
||||
fmt.Println("ERROR: ", err)
|
||||
}
|
||||
for _, a := range l {
|
||||
m.data[a.Id] = &a
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockArtist) Exists(id string) (bool, error) {
|
||||
@@ -35,4 +39,11 @@ func (m *MockArtist) Exists(id string) (bool, error) {
|
||||
}
|
||||
_, found := m.data[id];
|
||||
return found, nil
|
||||
}
|
||||
|
||||
func (m *MockArtist) Get(id string) (*domain.Artist, error) {
|
||||
if m.err {
|
||||
return nil, errors.New("Error!")
|
||||
}
|
||||
return m.data[id], nil
|
||||
}
|
||||
Reference in New Issue
Block a user