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
+46
View File
@@ -0,0 +1,46 @@
package mocks
import (
"errors"
"github.com/deluan/gosonic/domain"
)
func CreateMockPropertyRepo() *MockProperty {
return &MockProperty{data: make(map[string]string)}
}
type MockProperty struct {
domain.PropertyRepository
data map[string]string
err bool
}
func (m *MockProperty) SetError(err bool) {
m.err = err
}
func (m *MockProperty) Put(id string, value string) error {
if m.err {
return errors.New("Error!")
}
m.data[id] = value
return nil
}
func (m *MockProperty) Get(id string) (string, error) {
if m.err {
return "", errors.New("Error!")
} else {
return m.data[id], nil
}
}
func (m *MockProperty) DefaultGet(id string, defaultValue string) (string, error) {
v, err := m.Get(id)
if v == "" {
v = defaultValue
}
return v, err
}