mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 04:57:37 +03:00
38 lines
697 B
Go
38 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
|
|
}
|