Make mocks strongly typed

This commit is contained in:
Deluan
2020-10-27 10:48:37 -04:00
parent 6152fadd92
commit 313a088f86
6 changed files with 25 additions and 32 deletions
+2 -8
View File
@@ -1,9 +1,7 @@
package persistence
import (
"encoding/json"
"errors"
"fmt"
"github.com/deluan/navidrome/model"
)
@@ -24,13 +22,9 @@ func (m *MockAlbum) SetError(err bool) {
m.err = err
}
func (m *MockAlbum) SetData(j string) {
func (m *MockAlbum) SetData(albums model.Albums) {
m.data = make(map[string]model.Album)
m.all = model.Albums{}
err := json.Unmarshal([]byte(j), &m.all)
if err != nil {
fmt.Println("ERROR: ", err)
}
m.all = albums
for _, a := range m.all {
m.data[a.ID] = a
}