101 lines
2.8 KiB
Go
101 lines
2.8 KiB
Go
package seriessetmaster
|
|
|
|
type mockRepository struct {
|
|
findAllSeriesFunc func(search string) ([]SeriesSetMaster, error)
|
|
findAllSetsFunc func(search string, parentID uint) ([]SeriesSetMaster, error)
|
|
findByIDFunc func(id uint) (*SeriesSetMaster, error)
|
|
findBySetCodeFunc func(setCode string) (*SeriesSetMaster, error)
|
|
findCardImagesBySetIDFunc func(setID uint) ([]string, error)
|
|
createFunc func(m *SeriesSetMaster) error
|
|
createSetFunc func(m *SeriesSetMaster) error
|
|
updateFunc func(m *SeriesSetMaster) error
|
|
updateSetFunc func(m *SeriesSetMaster, oldParentID *uint) error
|
|
deleteCascadeFunc func(m *SeriesSetMaster) error
|
|
recalculateSeriesStatsFunc func(seriesID uint) error
|
|
recalculateSetStatsFunc func(setID uint) error
|
|
}
|
|
|
|
func (m *mockRepository) FindAllSeries(search string) ([]SeriesSetMaster, error) {
|
|
if m.findAllSeriesFunc != nil {
|
|
return m.findAllSeriesFunc(search)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockRepository) FindAllSets(search string, parentID uint) ([]SeriesSetMaster, error) {
|
|
if m.findAllSetsFunc != nil {
|
|
return m.findAllSetsFunc(search, parentID)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockRepository) FindByID(id uint) (*SeriesSetMaster, error) {
|
|
if m.findByIDFunc != nil {
|
|
return m.findByIDFunc(id)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockRepository) FindBySetCode(setCode string) (*SeriesSetMaster, error) {
|
|
if m.findBySetCodeFunc != nil {
|
|
return m.findBySetCodeFunc(setCode)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockRepository) FindCardImagesBySetID(setID uint) ([]string, error) {
|
|
if m.findCardImagesBySetIDFunc != nil {
|
|
return m.findCardImagesBySetIDFunc(setID)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockRepository) Create(item *SeriesSetMaster) error {
|
|
if m.createFunc != nil {
|
|
return m.createFunc(item)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *mockRepository) CreateSet(item *SeriesSetMaster) error {
|
|
if m.createSetFunc != nil {
|
|
return m.createSetFunc(item)
|
|
}
|
|
return m.Create(item)
|
|
}
|
|
|
|
func (m *mockRepository) Update(item *SeriesSetMaster) error {
|
|
if m.updateFunc != nil {
|
|
return m.updateFunc(item)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *mockRepository) UpdateSet(item *SeriesSetMaster, oldParentID *uint) error {
|
|
if m.updateSetFunc != nil {
|
|
return m.updateSetFunc(item, oldParentID)
|
|
}
|
|
return m.Update(item)
|
|
}
|
|
|
|
func (m *mockRepository) DeleteCascade(item *SeriesSetMaster) error {
|
|
if m.deleteCascadeFunc != nil {
|
|
return m.deleteCascadeFunc(item)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *mockRepository) RecalculateSeriesStats(seriesID uint) error {
|
|
if m.recalculateSeriesStatsFunc != nil {
|
|
return m.recalculateSeriesStatsFunc(seriesID)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *mockRepository) RecalculateSetStats(setID uint) error {
|
|
if m.recalculateSetStatsFunc != nil {
|
|
return m.recalculateSetStatsFunc(setID)
|
|
}
|
|
return nil
|
|
}
|