package tests
import (
"context"
"github.com/deluan/rest"
"github.com/navidrome/navidrome/model"
)
type MockLibraryService struct {
*MockLibraryRepo
}
type MockLibraryRestAdapter struct {
*MockLibraryRepo
}
func NewMockLibraryService() *MockLibraryService {
repo := &MockLibraryRepo{
Data: make(map[int]model.Library),
}
repo.SetData(model.Libraries{
{ID: 1, Name: "Test Library 1", Path: "/music/library1"},
{ID: 2, Name: "Test Library 2", Path: "/music/library2"},
})
return &MockLibraryService{MockLibraryRepo: repo}
}
func (m *MockLibraryService) Repository() rest.Repository[model.Library] {
return &MockLibraryRestAdapter{MockLibraryRepo: m.MockLibraryRepo}
}
func (a *MockLibraryRestAdapter) Delete(_ context.Context, ids ...string) error {
for _, id := range ids {
if err := a.DeleteByStringID(id); err != nil {
return err
}
}
return nil
}