WIP: renamed function and made it package internal as it gets orchestrated by another sync function
This commit is contained in:
parent
ca2620d426
commit
8c91dd2107
@ -16,7 +16,9 @@ import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
func SynchronizePiwigoCategories(piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error {
|
||||
func updatePiwigoCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error {
|
||||
logrus.Debug("Entering updatePiwigoCategoriesFromServer")
|
||||
defer logrus.Debug("Leaving updatePiwigoCategoriesFromServer")
|
||||
|
||||
categories, err := piwigoApi.GetAllCategories()
|
||||
if err != nil {
|
||||
@ -24,7 +26,6 @@ func SynchronizePiwigoCategories(piwigoApi piwigo.PiwigoCategoryApi, db datastor
|
||||
}
|
||||
|
||||
for _, pwgcat := range categories {
|
||||
|
||||
dbcat, err := db.GetCategoryByPiwigoId(pwgcat.Id)
|
||||
if err == datastore.ErrorRecordNotFound {
|
||||
logrus.Debugf("Adding category %s", pwgcat.Key)
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
//go:generate mockgen -destination=./piwigo_mock_test.go -package=category git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo PiwigoApi,PiwigoCategoryApi,PiwigoImageApi
|
||||
//go:generate mockgen -destination=./datastore_mock_test.go -package=category git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/datastore CategoryProvider
|
||||
|
||||
func Test_SynchronizePiwigoCategories_adds_new_categories(t *testing.T) {
|
||||
func Test_updatePiwigoCategoriesFromServer_adds_new_categories(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
@ -31,13 +31,13 @@ func Test_SynchronizePiwigoCategories_adds_new_categories(t *testing.T) {
|
||||
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
|
||||
piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1)
|
||||
|
||||
err := SynchronizePiwigoCategories(piwigoMock, dbmock)
|
||||
err := updatePiwigoCategoriesFromServer(piwigoMock, dbmock)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_SynchronizePiwigoCategories_updates_a_category(t *testing.T) {
|
||||
func Test_updatePiwigoCategoriesFromServer_updates_a_category(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
@ -68,7 +68,7 @@ func Test_SynchronizePiwigoCategories_updates_a_category(t *testing.T) {
|
||||
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
|
||||
piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1)
|
||||
|
||||
err := SynchronizePiwigoCategories(piwigoMock, dbmock)
|
||||
err := updatePiwigoCategoriesFromServer(piwigoMock, dbmock)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user