renamed piwigo interfaces to address build warnings

This commit is contained in:
Philipp Häfelfinger 2019-04-09 00:05:02 +02:00
parent 01761eb6ea
commit 4debc22f5c
12 changed files with 113 additions and 113 deletions

View File

@ -15,7 +15,7 @@ import (
"path/filepath" "path/filepath"
) )
func SynchronizeCategories(filesystemNodes map[string]*localFileStructure.FilesystemNode, piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error { func SynchronizeCategories(filesystemNodes map[string]*localFileStructure.FilesystemNode, piwigoApi piwigo.CategoryApi, db datastore.CategoryProvider) error {
logrus.Debug("Entering SynchronizeCategories...") logrus.Debug("Entering SynchronizeCategories...")
defer logrus.Debug("Leaving SynchronizeCategories...") defer logrus.Debug("Leaving SynchronizeCategories...")
@ -68,7 +68,7 @@ func addMissingPiwigoCategoriesToLocalDb(db datastore.CategoryProvider, fileSyst
return nil return nil
} }
func updatePiwigoCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error { func updatePiwigoCategoriesFromServer(piwigoApi piwigo.CategoryApi, db datastore.CategoryProvider) error {
logrus.Debug("Entering updatePiwigoCategoriesFromServer") logrus.Debug("Entering updatePiwigoCategoriesFromServer")
defer logrus.Debug("Leaving updatePiwigoCategoriesFromServer") defer logrus.Debug("Leaving updatePiwigoCategoriesFromServer")
@ -106,7 +106,7 @@ func updatePiwigoCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi, db dat
return nil return nil
} }
func createMissingCategories(piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error { func createMissingCategories(piwigoApi piwigo.CategoryApi, db datastore.CategoryProvider) error {
logrus.Debug("Entering createMissingCategories...") logrus.Debug("Entering createMissingCategories...")
defer logrus.Debug("Leaving createMissingCategories...") defer logrus.Debug("Leaving createMissingCategories...")

View File

@ -15,7 +15,7 @@ import (
"time" "time"
) )
//go:generate mockgen -destination=./piwigo_mock_test.go -package=category git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo PiwigoCategoryApi,PiwigoImageApi //go:generate mockgen -destination=./piwigo_mock_test.go -package=category git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo CategoryApi,ImageApi
//go:generate mockgen -destination=./datastore_mock_test.go -package=category git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/datastore CategoryProvider //go:generate mockgen -destination=./datastore_mock_test.go -package=category git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/datastore CategoryProvider
func Test_updatePiwigoCategoriesFromServer_adds_new_categories(t *testing.T) { func Test_updatePiwigoCategoriesFromServer_adds_new_categories(t *testing.T) {
@ -31,7 +31,7 @@ func Test_updatePiwigoCategoriesFromServer_adds_new_categories(t *testing.T) {
dbmock.EXPECT().SaveCategory(cat).Times(1) dbmock.EXPECT().SaveCategory(cat).Times(1)
} }
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl) piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1) piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1)
err := updatePiwigoCategoriesFromServer(piwigoMock, dbmock) err := updatePiwigoCategoriesFromServer(piwigoMock, dbmock)
@ -62,7 +62,7 @@ func Test_updatePiwigoCategoriesFromServer_updates_a_category(t *testing.T) {
dbmock.EXPECT().SaveCategory(expectedCategory).Times(1) dbmock.EXPECT().SaveCategory(expectedCategory).Times(1)
dbmock.EXPECT().SaveCategory(gomock.Any()).Times(1) dbmock.EXPECT().SaveCategory(gomock.Any()).Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl) piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1) piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1)
err := updatePiwigoCategoriesFromServer(piwigoMock, dbmock) err := updatePiwigoCategoriesFromServer(piwigoMock, dbmock)
@ -80,7 +80,7 @@ func Test_createMissingCategories_does_not_call_piwigo_if_there_is_no_category_m
dbmock := NewMockCategoryProvider(mockCtrl) dbmock := NewMockCategoryProvider(mockCtrl)
dbmock.EXPECT().GetCategoriesToCreate().Return(categoriesToCreate, nil).Times(1) dbmock.EXPECT().GetCategoriesToCreate().Return(categoriesToCreate, nil).Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl) piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().CreateCategory(gomock.Any(), gomock.Any()).Times(0) piwigoMock.EXPECT().CreateCategory(gomock.Any(), gomock.Any()).Times(0)
err := createMissingCategories(piwigoMock, dbmock) err := createMissingCategories(piwigoMock, dbmock)
@ -194,7 +194,7 @@ func Test_createMissingCategories_calls_piwigo_api_and_saves_returned_id(t *test
dbmock.EXPECT().GetCategoriesToCreate().Return(categoriesToCreate, nil).Times(1) dbmock.EXPECT().GetCategoriesToCreate().Return(categoriesToCreate, nil).Times(1)
dbmock.EXPECT().SaveCategory(expectedCategory).Return(nil).Times(1) dbmock.EXPECT().SaveCategory(expectedCategory).Return(nil).Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl) piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().CreateCategory(0, category.Name).Return(1, nil).Times(1) piwigoMock.EXPECT().CreateCategory(0, category.Name).Return(1, nil).Times(1)
err := createMissingCategories(piwigoMock, dbmock) err := createMissingCategories(piwigoMock, dbmock)
@ -288,7 +288,7 @@ func Test_SynchronizeCategories(t *testing.T) {
dbmock := NewMockCategoryProvider(mockCtrl) dbmock := NewMockCategoryProvider(mockCtrl)
dbmock.EXPECT().GetCategoriesToCreate().Times(1) dbmock.EXPECT().GetCategoriesToCreate().Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl) piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().GetAllCategories().Times(1) piwigoMock.EXPECT().GetAllCategories().Times(1)
err := SynchronizeCategories(fileSystemNodes, piwigoMock, dbmock) err := SynchronizeCategories(fileSystemNodes, piwigoMock, dbmock)

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT. // Code generated by MockGen. DO NOT EDIT.
// Source: git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo (interfaces: PiwigoCategoryApi,PiwigoImageApi) // Source: git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo (interfaces: CategoryApi,ImageApi)
// Package category is a generated GoMock package. // Package category is a generated GoMock package.
package category package category
@ -10,31 +10,31 @@ import (
reflect "reflect" reflect "reflect"
) )
// MockPiwigoCategoryApi is a mock of PiwigoCategoryApi interface // MockCategoryApi is a mock of CategoryApi interface
type MockPiwigoCategoryApi struct { type MockCategoryApi struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockPiwigoCategoryApiMockRecorder recorder *MockCategoryApiMockRecorder
} }
// MockPiwigoCategoryApiMockRecorder is the mock recorder for MockPiwigoCategoryApi // MockCategoryApiMockRecorder is the mock recorder for MockCategoryApi
type MockPiwigoCategoryApiMockRecorder struct { type MockCategoryApiMockRecorder struct {
mock *MockPiwigoCategoryApi mock *MockCategoryApi
} }
// NewMockPiwigoCategoryApi creates a new mock instance // NewMockCategoryApi creates a new mock instance
func NewMockPiwigoCategoryApi(ctrl *gomock.Controller) *MockPiwigoCategoryApi { func NewMockCategoryApi(ctrl *gomock.Controller) *MockCategoryApi {
mock := &MockPiwigoCategoryApi{ctrl: ctrl} mock := &MockCategoryApi{ctrl: ctrl}
mock.recorder = &MockPiwigoCategoryApiMockRecorder{mock} mock.recorder = &MockCategoryApiMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use // EXPECT returns an object that allows the caller to indicate expected use
func (m *MockPiwigoCategoryApi) EXPECT() *MockPiwigoCategoryApiMockRecorder { func (m *MockCategoryApi) EXPECT() *MockCategoryApiMockRecorder {
return m.recorder return m.recorder
} }
// CreateCategory mocks base method // CreateCategory mocks base method
func (m *MockPiwigoCategoryApi) CreateCategory(arg0 int, arg1 string) (int, error) { func (m *MockCategoryApi) CreateCategory(arg0 int, arg1 string) (int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateCategory", arg0, arg1) ret := m.ctrl.Call(m, "CreateCategory", arg0, arg1)
ret0, _ := ret[0].(int) ret0, _ := ret[0].(int)
@ -43,13 +43,13 @@ func (m *MockPiwigoCategoryApi) CreateCategory(arg0 int, arg1 string) (int, erro
} }
// CreateCategory indicates an expected call of CreateCategory // CreateCategory indicates an expected call of CreateCategory
func (mr *MockPiwigoCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call { func (mr *MockCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCategory", reflect.TypeOf((*MockPiwigoCategoryApi)(nil).CreateCategory), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCategory", reflect.TypeOf((*MockCategoryApi)(nil).CreateCategory), arg0, arg1)
} }
// GetAllCategories mocks base method // GetAllCategories mocks base method
func (m *MockPiwigoCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) { func (m *MockCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllCategories") ret := m.ctrl.Call(m, "GetAllCategories")
ret0, _ := ret[0].(map[string]*piwigo.Category) ret0, _ := ret[0].(map[string]*piwigo.Category)
@ -58,36 +58,36 @@ func (m *MockPiwigoCategoryApi) GetAllCategories() (map[string]*piwigo.Category,
} }
// GetAllCategories indicates an expected call of GetAllCategories // GetAllCategories indicates an expected call of GetAllCategories
func (mr *MockPiwigoCategoryApiMockRecorder) GetAllCategories() *gomock.Call { func (mr *MockCategoryApiMockRecorder) GetAllCategories() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllCategories", reflect.TypeOf((*MockPiwigoCategoryApi)(nil).GetAllCategories)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllCategories", reflect.TypeOf((*MockCategoryApi)(nil).GetAllCategories))
} }
// MockPiwigoImageApi is a mock of PiwigoImageApi interface // MockImageApi is a mock of ImageApi interface
type MockPiwigoImageApi struct { type MockImageApi struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockPiwigoImageApiMockRecorder recorder *MockImageApiMockRecorder
} }
// MockPiwigoImageApiMockRecorder is the mock recorder for MockPiwigoImageApi // MockImageApiMockRecorder is the mock recorder for MockImageApi
type MockPiwigoImageApiMockRecorder struct { type MockImageApiMockRecorder struct {
mock *MockPiwigoImageApi mock *MockImageApi
} }
// NewMockPiwigoImageApi creates a new mock instance // NewMockImageApi creates a new mock instance
func NewMockPiwigoImageApi(ctrl *gomock.Controller) *MockPiwigoImageApi { func NewMockImageApi(ctrl *gomock.Controller) *MockImageApi {
mock := &MockPiwigoImageApi{ctrl: ctrl} mock := &MockImageApi{ctrl: ctrl}
mock.recorder = &MockPiwigoImageApiMockRecorder{mock} mock.recorder = &MockImageApiMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use // EXPECT returns an object that allows the caller to indicate expected use
func (m *MockPiwigoImageApi) EXPECT() *MockPiwigoImageApiMockRecorder { func (m *MockImageApi) EXPECT() *MockImageApiMockRecorder {
return m.recorder return m.recorder
} }
// DeleteImages mocks base method // DeleteImages mocks base method
func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error { func (m *MockImageApi) DeleteImages(arg0 []int) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteImages", arg0) ret := m.ctrl.Call(m, "DeleteImages", arg0)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -95,13 +95,13 @@ func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error {
} }
// DeleteImages indicates an expected call of DeleteImages // DeleteImages indicates an expected call of DeleteImages
func (mr *MockPiwigoImageApiMockRecorder) DeleteImages(arg0 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) DeleteImages(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteImages", reflect.TypeOf((*MockPiwigoImageApi)(nil).DeleteImages), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteImages", reflect.TypeOf((*MockImageApi)(nil).DeleteImages), arg0)
} }
// ImageCheckFile mocks base method // ImageCheckFile mocks base method
func (m *MockPiwigoImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) { func (m *MockImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImageCheckFile", arg0, arg1) ret := m.ctrl.Call(m, "ImageCheckFile", arg0, arg1)
ret0, _ := ret[0].(int) ret0, _ := ret[0].(int)
@ -110,13 +110,13 @@ func (m *MockPiwigoImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error)
} }
// ImageCheckFile indicates an expected call of ImageCheckFile // ImageCheckFile indicates an expected call of ImageCheckFile
func (mr *MockPiwigoImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageCheckFile", reflect.TypeOf((*MockPiwigoImageApi)(nil).ImageCheckFile), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageCheckFile", reflect.TypeOf((*MockImageApi)(nil).ImageCheckFile), arg0, arg1)
} }
// ImagesExistOnPiwigo mocks base method // ImagesExistOnPiwigo mocks base method
func (m *MockPiwigoImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) { func (m *MockImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImagesExistOnPiwigo", arg0) ret := m.ctrl.Call(m, "ImagesExistOnPiwigo", arg0)
ret0, _ := ret[0].(map[string]int) ret0, _ := ret[0].(map[string]int)
@ -125,13 +125,13 @@ func (m *MockPiwigoImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int,
} }
// ImagesExistOnPiwigo indicates an expected call of ImagesExistOnPiwigo // ImagesExistOnPiwigo indicates an expected call of ImagesExistOnPiwigo
func (mr *MockPiwigoImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImagesExistOnPiwigo", reflect.TypeOf((*MockPiwigoImageApi)(nil).ImagesExistOnPiwigo), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImagesExistOnPiwigo", reflect.TypeOf((*MockImageApi)(nil).ImagesExistOnPiwigo), arg0)
} }
// UploadImage mocks base method // UploadImage mocks base method
func (m *MockPiwigoImageApi) UploadImage(arg0 int, arg1, arg2 string, arg3 int) (int, error) { func (m *MockImageApi) UploadImage(arg0 int, arg1, arg2 string, arg3 int) (int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UploadImage", arg0, arg1, arg2, arg3) ret := m.ctrl.Call(m, "UploadImage", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(int) ret0, _ := ret[0].(int)
@ -140,7 +140,7 @@ func (m *MockPiwigoImageApi) UploadImage(arg0 int, arg1, arg2 string, arg3 int)
} }
// UploadImage indicates an expected call of UploadImage // UploadImage indicates an expected call of UploadImage
func (mr *MockPiwigoImageApiMockRecorder) UploadImage(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) UploadImage(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UploadImage", reflect.TypeOf((*MockPiwigoImageApi)(nil).UploadImage), arg0, arg1, arg2, arg3) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UploadImage", reflect.TypeOf((*MockImageApi)(nil).UploadImage), arg0, arg1, arg2, arg3)
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
func DeleteImages(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.ImageMetadataProvider) error { func DeleteImages(piwigoCtx piwigo.ImageApi, metadataProvider datastore.ImageMetadataProvider) error {
logrus.Debug("Starting deleteImages") logrus.Debug("Starting deleteImages")
defer logrus.Debug("Finished deleteImages successfully") defer logrus.Debug("Finished deleteImages successfully")

View File

@ -24,7 +24,7 @@ func Test_deleteImages_should_call_piwigo_and_remove_metadata(t *testing.T) {
dbmock.EXPECT().ImageMetadataToDelete().Times(1).Return(images, nil) dbmock.EXPECT().ImageMetadataToDelete().Times(1).Return(images, nil)
dbmock.EXPECT().DeleteMarkedImages().Times(1).Return(nil) dbmock.EXPECT().DeleteMarkedImages().Times(1).Return(nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().DeleteImages([]int{5}).Times(1).Return(nil) piwigomock.EXPECT().DeleteImages([]int{5}).Times(1).Return(nil)
err := DeleteImages(piwigomock, dbmock) err := DeleteImages(piwigomock, dbmock)
@ -46,7 +46,7 @@ func Test_deleteImages_should_not_call_piwigo_for_not_uploaded_images_and_remove
dbmock.EXPECT().ImageMetadataToDelete().Times(1).Return(images, nil) dbmock.EXPECT().ImageMetadataToDelete().Times(1).Return(images, nil)
dbmock.EXPECT().DeleteMarkedImages().Times(1).Return(nil) dbmock.EXPECT().DeleteMarkedImages().Times(1).Return(nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().DeleteImages(gomock.Any()).Times(0) piwigomock.EXPECT().DeleteImages(gomock.Any()).Times(0)
err := DeleteImages(piwigomock, dbmock) err := DeleteImages(piwigomock, dbmock)
@ -65,7 +65,7 @@ func Test_deleteImages_should_not_call_anything_if_no_images_are_marked_for_dele
dbmock.EXPECT().ImageMetadataToDelete().Times(1).Return(images, nil) dbmock.EXPECT().ImageMetadataToDelete().Times(1).Return(images, nil)
dbmock.EXPECT().DeleteMarkedImages().Times(0) dbmock.EXPECT().DeleteMarkedImages().Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().DeleteImages(gomock.Any()).Times(0) piwigomock.EXPECT().DeleteImages(gomock.Any()).Times(0)
err := DeleteImages(piwigomock, dbmock) err := DeleteImages(piwigomock, dbmock)

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT. // Code generated by MockGen. DO NOT EDIT.
// Source: git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo (interfaces: PiwigoCategoryApi,PiwigoImageApi) // Source: git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo (interfaces: CategoryApi,ImageApi)
// Package images is a generated GoMock package. // Package images is a generated GoMock package.
package images package images
@ -10,31 +10,31 @@ import (
reflect "reflect" reflect "reflect"
) )
// MockPiwigoCategoryApi is a mock of PiwigoCategoryApi interface // MockCategoryApi is a mock of CategoryApi interface
type MockPiwigoCategoryApi struct { type MockCategoryApi struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockPiwigoCategoryApiMockRecorder recorder *MockCategoryApiMockRecorder
} }
// MockPiwigoCategoryApiMockRecorder is the mock recorder for MockPiwigoCategoryApi // MockCategoryApiMockRecorder is the mock recorder for MockCategoryApi
type MockPiwigoCategoryApiMockRecorder struct { type MockCategoryApiMockRecorder struct {
mock *MockPiwigoCategoryApi mock *MockCategoryApi
} }
// NewMockPiwigoCategoryApi creates a new mock instance // NewMockCategoryApi creates a new mock instance
func NewMockPiwigoCategoryApi(ctrl *gomock.Controller) *MockPiwigoCategoryApi { func NewMockCategoryApi(ctrl *gomock.Controller) *MockCategoryApi {
mock := &MockPiwigoCategoryApi{ctrl: ctrl} mock := &MockCategoryApi{ctrl: ctrl}
mock.recorder = &MockPiwigoCategoryApiMockRecorder{mock} mock.recorder = &MockCategoryApiMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use // EXPECT returns an object that allows the caller to indicate expected use
func (m *MockPiwigoCategoryApi) EXPECT() *MockPiwigoCategoryApiMockRecorder { func (m *MockCategoryApi) EXPECT() *MockCategoryApiMockRecorder {
return m.recorder return m.recorder
} }
// CreateCategory mocks base method // CreateCategory mocks base method
func (m *MockPiwigoCategoryApi) CreateCategory(arg0 int, arg1 string) (int, error) { func (m *MockCategoryApi) CreateCategory(arg0 int, arg1 string) (int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateCategory", arg0, arg1) ret := m.ctrl.Call(m, "CreateCategory", arg0, arg1)
ret0, _ := ret[0].(int) ret0, _ := ret[0].(int)
@ -43,13 +43,13 @@ func (m *MockPiwigoCategoryApi) CreateCategory(arg0 int, arg1 string) (int, erro
} }
// CreateCategory indicates an expected call of CreateCategory // CreateCategory indicates an expected call of CreateCategory
func (mr *MockPiwigoCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call { func (mr *MockCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCategory", reflect.TypeOf((*MockPiwigoCategoryApi)(nil).CreateCategory), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCategory", reflect.TypeOf((*MockCategoryApi)(nil).CreateCategory), arg0, arg1)
} }
// GetAllCategories mocks base method // GetAllCategories mocks base method
func (m *MockPiwigoCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) { func (m *MockCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllCategories") ret := m.ctrl.Call(m, "GetAllCategories")
ret0, _ := ret[0].(map[string]*piwigo.Category) ret0, _ := ret[0].(map[string]*piwigo.Category)
@ -58,36 +58,36 @@ func (m *MockPiwigoCategoryApi) GetAllCategories() (map[string]*piwigo.Category,
} }
// GetAllCategories indicates an expected call of GetAllCategories // GetAllCategories indicates an expected call of GetAllCategories
func (mr *MockPiwigoCategoryApiMockRecorder) GetAllCategories() *gomock.Call { func (mr *MockCategoryApiMockRecorder) GetAllCategories() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllCategories", reflect.TypeOf((*MockPiwigoCategoryApi)(nil).GetAllCategories)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllCategories", reflect.TypeOf((*MockCategoryApi)(nil).GetAllCategories))
} }
// MockPiwigoImageApi is a mock of PiwigoImageApi interface // MockImageApi is a mock of ImageApi interface
type MockPiwigoImageApi struct { type MockImageApi struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockPiwigoImageApiMockRecorder recorder *MockImageApiMockRecorder
} }
// MockPiwigoImageApiMockRecorder is the mock recorder for MockPiwigoImageApi // MockImageApiMockRecorder is the mock recorder for MockImageApi
type MockPiwigoImageApiMockRecorder struct { type MockImageApiMockRecorder struct {
mock *MockPiwigoImageApi mock *MockImageApi
} }
// NewMockPiwigoImageApi creates a new mock instance // NewMockImageApi creates a new mock instance
func NewMockPiwigoImageApi(ctrl *gomock.Controller) *MockPiwigoImageApi { func NewMockImageApi(ctrl *gomock.Controller) *MockImageApi {
mock := &MockPiwigoImageApi{ctrl: ctrl} mock := &MockImageApi{ctrl: ctrl}
mock.recorder = &MockPiwigoImageApiMockRecorder{mock} mock.recorder = &MockImageApiMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use // EXPECT returns an object that allows the caller to indicate expected use
func (m *MockPiwigoImageApi) EXPECT() *MockPiwigoImageApiMockRecorder { func (m *MockImageApi) EXPECT() *MockImageApiMockRecorder {
return m.recorder return m.recorder
} }
// DeleteImages mocks base method // DeleteImages mocks base method
func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error { func (m *MockImageApi) DeleteImages(arg0 []int) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteImages", arg0) ret := m.ctrl.Call(m, "DeleteImages", arg0)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
@ -95,13 +95,13 @@ func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error {
} }
// DeleteImages indicates an expected call of DeleteImages // DeleteImages indicates an expected call of DeleteImages
func (mr *MockPiwigoImageApiMockRecorder) DeleteImages(arg0 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) DeleteImages(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteImages", reflect.TypeOf((*MockPiwigoImageApi)(nil).DeleteImages), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteImages", reflect.TypeOf((*MockImageApi)(nil).DeleteImages), arg0)
} }
// ImageCheckFile mocks base method // ImageCheckFile mocks base method
func (m *MockPiwigoImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) { func (m *MockImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImageCheckFile", arg0, arg1) ret := m.ctrl.Call(m, "ImageCheckFile", arg0, arg1)
ret0, _ := ret[0].(int) ret0, _ := ret[0].(int)
@ -110,13 +110,13 @@ func (m *MockPiwigoImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error)
} }
// ImageCheckFile indicates an expected call of ImageCheckFile // ImageCheckFile indicates an expected call of ImageCheckFile
func (mr *MockPiwigoImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageCheckFile", reflect.TypeOf((*MockPiwigoImageApi)(nil).ImageCheckFile), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageCheckFile", reflect.TypeOf((*MockImageApi)(nil).ImageCheckFile), arg0, arg1)
} }
// ImagesExistOnPiwigo mocks base method // ImagesExistOnPiwigo mocks base method
func (m *MockPiwigoImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) { func (m *MockImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImagesExistOnPiwigo", arg0) ret := m.ctrl.Call(m, "ImagesExistOnPiwigo", arg0)
ret0, _ := ret[0].(map[string]int) ret0, _ := ret[0].(map[string]int)
@ -125,13 +125,13 @@ func (m *MockPiwigoImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int,
} }
// ImagesExistOnPiwigo indicates an expected call of ImagesExistOnPiwigo // ImagesExistOnPiwigo indicates an expected call of ImagesExistOnPiwigo
func (mr *MockPiwigoImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImagesExistOnPiwigo", reflect.TypeOf((*MockPiwigoImageApi)(nil).ImagesExistOnPiwigo), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImagesExistOnPiwigo", reflect.TypeOf((*MockImageApi)(nil).ImagesExistOnPiwigo), arg0)
} }
// UploadImage mocks base method // UploadImage mocks base method
func (m *MockPiwigoImageApi) UploadImage(arg0 int, arg1, arg2 string, arg3 int) (int, error) { func (m *MockImageApi) UploadImage(arg0 int, arg1, arg2 string, arg3 int) (int, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UploadImage", arg0, arg1, arg2, arg3) ret := m.ctrl.Call(m, "UploadImage", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(int) ret0, _ := ret[0].(int)
@ -140,7 +140,7 @@ func (m *MockPiwigoImageApi) UploadImage(arg0 int, arg1, arg2 string, arg3 int)
} }
// UploadImage indicates an expected call of UploadImage // UploadImage indicates an expected call of UploadImage
func (mr *MockPiwigoImageApiMockRecorder) UploadImage(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { func (mr *MockImageApiMockRecorder) UploadImage(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UploadImage", reflect.TypeOf((*MockPiwigoImageApi)(nil).UploadImage), arg0, arg1, arg2, arg3) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UploadImage", reflect.TypeOf((*MockImageApi)(nil).UploadImage), arg0, arg1, arg2, arg3)
} }

View File

@ -5,7 +5,7 @@
package images package images
//go:generate mockgen -destination=./piwigo_mock_test.go -package=images git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo PiwigoCategoryApi,PiwigoImageApi //go:generate mockgen -destination=./piwigo_mock_test.go -package=images git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo CategoryApi,ImageApi
//go:generate mockgen -destination=./datastore_mock_test.go -package=images git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/datastore ImageMetadataProvider,CategoryProvider //go:generate mockgen -destination=./datastore_mock_test.go -package=images git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/datastore ImageMetadataProvider,CategoryProvider
import ( import (

View File

@ -12,7 +12,7 @@ import (
) )
// This method aggregates the check for files with missing piwigoids and if changed files need to be uploaded again. // This method aggregates the check for files with missing piwigoids and if changed files need to be uploaded again.
func SynchronizePiwigoMetadata(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.ImageMetadataProvider) error { func SynchronizePiwigoMetadata(piwigoCtx piwigo.ImageApi, metadataProvider datastore.ImageMetadataProvider) error {
logrus.Debug("Entering SynchronizePiwigoMetadata") logrus.Debug("Entering SynchronizePiwigoMetadata")
defer logrus.Debug("Leaving SynchronizePiwigoMetadata") defer logrus.Debug("Leaving SynchronizePiwigoMetadata")
@ -32,7 +32,7 @@ func SynchronizePiwigoMetadata(piwigoCtx piwigo.PiwigoImageApi, metadataProvider
// This function calls piwigo and checks if the given md5sum is already present. // This function calls piwigo and checks if the given md5sum is already present.
// Only files without a piwigo id are used to query the server. // Only files without a piwigo id are used to query the server.
func updatePiwigoIdIfAlreadyUploaded(provider datastore.ImageMetadataProvider, piwigoCtx piwigo.PiwigoImageApi) error { func updatePiwigoIdIfAlreadyUploaded(provider datastore.ImageMetadataProvider, piwigoCtx piwigo.ImageApi) error {
logrus.Info("checking for pending files that are already on piwigo and updating piwigoids...") logrus.Info("checking for pending files that are already on piwigo and updating piwigoids...")
defer logrus.Info("finshed checking for pending files that are already on piwigo and updating piwigoids...") defer logrus.Info("finshed checking for pending files that are already on piwigo and updating piwigoids...")
@ -80,7 +80,7 @@ func updatePiwigoIdIfAlreadyUploaded(provider datastore.ImageMetadataProvider, p
} }
// Check all images with upload required if they are really changed and need to be uploaded to the server. // Check all images with upload required if they are really changed and need to be uploaded to the server.
func checkPiwigoForChangedImages(provider datastore.ImageMetadataProvider, piwigoCtx piwigo.PiwigoImageApi) error { func checkPiwigoForChangedImages(provider datastore.ImageMetadataProvider, piwigoCtx piwigo.ImageApi) error {
logrus.Info("Checking pending files if they really differ from the version in piwigo...") logrus.Info("Checking pending files if they really differ from the version in piwigo...")
defer logrus.Info("Finished checking pending files if they really differ from the version in piwigo...") defer logrus.Info("Finished checking pending files if they really differ from the version in piwigo...")

View File

@ -22,7 +22,7 @@ func Test_checkPiwigoForChangedImages_none_with_piwigoId(t *testing.T) {
dbmock := NewMockImageMetadataProvider(mockCtrl) dbmock := NewMockImageMetadataProvider(mockCtrl)
dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0) piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0)
piwigomock.EXPECT().ImageCheckFile(gomock.Any(), gomock.Any()).Times(0) piwigomock.EXPECT().ImageCheckFile(gomock.Any(), gomock.Any()).Times(0)
@ -41,7 +41,7 @@ func Test_checkPiwigoForChangedImages_with_empty_list(t *testing.T) {
dbmock := NewMockImageMetadataProvider(mockCtrl) dbmock := NewMockImageMetadataProvider(mockCtrl)
dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0) piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0)
piwigomock.EXPECT().ImageCheckFile(gomock.Any(), gomock.Any()).Times(0) piwigomock.EXPECT().ImageCheckFile(gomock.Any(), gomock.Any()).Times(0)
@ -69,7 +69,7 @@ func Test_checkPiwigoForChangedImages_should_call_piwigo_set_uploadRequired_to_f
imgExpected.UploadRequired = false imgExpected.UploadRequired = false
dbmock.EXPECT().SaveImageMetadata(imgExpected).Times(1) dbmock.EXPECT().SaveImageMetadata(imgExpected).Times(1)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImageCheckFile(1, "1234").Return(piwigo.ImageStateUptodate, nil) piwigomock.EXPECT().ImageCheckFile(1, "1234").Return(piwigo.ImageStateUptodate, nil)
err := checkPiwigoForChangedImages(dbmock, piwigomock) err := checkPiwigoForChangedImages(dbmock, piwigomock)
@ -93,7 +93,7 @@ func Test_checkPiwigoForChangedImages_return_image_differs(t *testing.T) {
dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil)
dbmock.EXPECT().SaveImageMetadata(gomock.Any()).Times(0) dbmock.EXPECT().SaveImageMetadata(gomock.Any()).Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImageCheckFile(1, "1234").Return(piwigo.ImageStateDifferent, nil) piwigomock.EXPECT().ImageCheckFile(1, "1234").Return(piwigo.ImageStateDifferent, nil)
err := checkPiwigoForChangedImages(dbmock, piwigomock) err := checkPiwigoForChangedImages(dbmock, piwigomock)
@ -112,7 +112,7 @@ func Test_updatePiwigoIdIfAlreadyUploaded_without_images_to_upload(t *testing.T)
dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil)
dbmock.EXPECT().SavePiwigoIdAndUpdateUploadFlag(gomock.Any(), gomock.Any()).Times(0) dbmock.EXPECT().SavePiwigoIdAndUpdateUploadFlag(gomock.Any(), gomock.Any()).Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0) piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0)
err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock) err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock)
@ -137,7 +137,7 @@ func Test_updatePiwigoIdIfAlreadyUploaded_without_image_to_check(t *testing.T) {
dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Return(images, nil)
dbmock.EXPECT().SavePiwigoIdAndUpdateUploadFlag(gomock.Any(), gomock.Any()).Times(0) dbmock.EXPECT().SavePiwigoIdAndUpdateUploadFlag(gomock.Any(), gomock.Any()).Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0) piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0)
err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock) err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock)
@ -165,7 +165,7 @@ func Test_updatePiwigoIdIfAlreadyUploaded_with_image_to_check(t *testing.T) {
piwigoResponose := make(map[string]int) piwigoResponose := make(map[string]int)
piwigoResponose["1234"] = 1 piwigoResponose["1234"] = 1
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(1).Return(piwigoResponose, nil) piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(1).Return(piwigoResponose, nil)
err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock) err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock)
@ -192,7 +192,7 @@ func Test_updatePiwigoIdIfAlreadyUploaded_with_image_to_check_missing_on_server(
piwigoResponose := make(map[string]int) piwigoResponose := make(map[string]int)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(1).Return(piwigoResponose, nil) piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(1).Return(piwigoResponose, nil)
err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock) err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock)

View File

@ -14,7 +14,7 @@ import (
// Uploads the pending images to the piwigo gallery and assign the category of to the image. // Uploads the pending images to the piwigo gallery and assign the category of to the image.
// Update local metadata and set upload flag to false. Also updates the piwigo image id if there was a difference. // Update local metadata and set upload flag to false. Also updates the piwigo image id if there was a difference.
func UploadImages(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.ImageMetadataProvider, numberOfWorkers int) error { func UploadImages(piwigoCtx piwigo.ImageApi, metadataProvider datastore.ImageMetadataProvider, numberOfWorkers int) error {
logrus.Debug("Starting uploadImages") logrus.Debug("Starting uploadImages")
defer logrus.Debug("Finished uploadImages successfully") defer logrus.Debug("Finished uploadImages successfully")
@ -51,7 +51,7 @@ func UploadImages(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.Im
return nil return nil
} }
func uploadQueueWorker(workQueue <-chan datastore.ImageMetaData, piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.ImageMetadataProvider, waitGroup *sync.WaitGroup) { func uploadQueueWorker(workQueue <-chan datastore.ImageMetaData, piwigoCtx piwigo.ImageApi, metadataProvider datastore.ImageMetadataProvider, waitGroup *sync.WaitGroup) {
for img := range workQueue { for img := range workQueue {
logrus.Debugf("%s: uploading image to piwigo", img.FullImagePath) logrus.Debugf("%s: uploading image to piwigo", img.FullImagePath)

View File

@ -26,7 +26,7 @@ func Test_uploadImages_saves_new_id_to_db(t *testing.T) {
dbmock.EXPECT().ImageMetadataToUpload().Times(1).Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Times(1).Return(images, nil)
dbmock.EXPECT().SaveImageMetadata(imgToSave).Times(1) dbmock.EXPECT().SaveImageMetadata(imgToSave).Times(1)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().UploadImage(0, "/nonexisting/file.jpg", "1234", 2).Times(1).Return(5, nil) piwigomock.EXPECT().UploadImage(0, "/nonexisting/file.jpg", "1234", 2).Times(1).Return(5, nil)
err := UploadImages(piwigomock, dbmock, 1) err := UploadImages(piwigomock, dbmock, 1)
@ -49,7 +49,7 @@ func Test_uploadImages_saves_same_id_to_db(t *testing.T) {
dbmock.EXPECT().ImageMetadataToUpload().Times(1).Return(images, nil) dbmock.EXPECT().ImageMetadataToUpload().Times(1).Return(images, nil)
dbmock.EXPECT().SaveImageMetadata(imgToSave).Times(1) dbmock.EXPECT().SaveImageMetadata(imgToSave).Times(1)
piwigomock := NewMockPiwigoImageApi(mockCtrl) piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().UploadImage(5, "/nonexisting/file.jpg", "1234", 2).Times(1).Return(5, nil) piwigomock.EXPECT().UploadImage(5, "/nonexisting/file.jpg", "1234", 2).Times(1).Return(5, nil)
err := UploadImages(piwigomock, dbmock, 1) err := UploadImages(piwigomock, dbmock, 1)

View File

@ -18,12 +18,12 @@ import (
"strings" "strings"
) )
type PiwigoCategoryApi interface { type CategoryApi interface {
GetAllCategories() (map[string]*Category, error) GetAllCategories() (map[string]*Category, error)
CreateCategory(parentId int, name string) (int, error) CreateCategory(parentId int, name string) (int, error)
} }
type PiwigoImageApi interface { type ImageApi interface {
ImageCheckFile(piwigoId int, md5sum string) (int, error) ImageCheckFile(piwigoId int, md5sum string) (int, error)
ImagesExistOnPiwigo(md5sums []string) (map[string]int, error) ImagesExistOnPiwigo(md5sums []string) (map[string]int, error)
UploadImage(piwigoId int, filePath string, md5sum string, category int) (int, error) UploadImage(piwigoId int, filePath string, md5sum string, category int) (int, error)