mirror of
https://github.com/navidrome/navidrome.git
synced 2024-08-28 13:31:28 +02:00
39 lines
697 B
Go
39 lines
697 B
Go
package persistence
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/cloudsonic/sonic-server/domain"
|
|
)
|
|
|
|
func CreateMockArtistIndexRepo() *MockArtistIndex {
|
|
return &MockArtistIndex{}
|
|
}
|
|
|
|
type MockArtistIndex struct {
|
|
domain.ArtistIndexRepository
|
|
data domain.ArtistIndexes
|
|
err bool
|
|
}
|
|
|
|
func (m *MockArtistIndex) SetError(err bool) {
|
|
m.err = err
|
|
}
|
|
|
|
func (m *MockArtistIndex) SetData(j string, length int) {
|
|
m.data = make(domain.ArtistIndexes, length)
|
|
err := json.Unmarshal([]byte(j), &m.data)
|
|
if err != nil {
|
|
fmt.Println("ERROR: ", err)
|
|
}
|
|
}
|
|
|
|
func (m *MockArtistIndex) GetAll() (domain.ArtistIndexes, error) {
|
|
if m.err {
|
|
return nil, errors.New("Error!")
|
|
}
|
|
return m.data, nil
|
|
}
|