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"
)
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...")
defer logrus.Debug("Leaving SynchronizeCategories...")
@ -68,7 +68,7 @@ func addMissingPiwigoCategoriesToLocalDb(db datastore.CategoryProvider, fileSyst
return nil
}
func updatePiwigoCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error {
func updatePiwigoCategoriesFromServer(piwigoApi piwigo.CategoryApi, db datastore.CategoryProvider) error {
logrus.Debug("Entering updatePiwigoCategoriesFromServer")
defer logrus.Debug("Leaving updatePiwigoCategoriesFromServer")
@ -106,7 +106,7 @@ func updatePiwigoCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi, db dat
return nil
}
func createMissingCategories(piwigoApi piwigo.PiwigoCategoryApi, db datastore.CategoryProvider) error {
func createMissingCategories(piwigoApi piwigo.CategoryApi, db datastore.CategoryProvider) error {
logrus.Debug("Entering createMissingCategories...")
defer logrus.Debug("Leaving createMissingCategories...")

View File

@ -15,7 +15,7 @@ import (
"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
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)
}
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1)
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(gomock.Any()).Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().GetAllCategories().Return(piwigoCategories, nil).Times(1)
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.EXPECT().GetCategoriesToCreate().Return(categoriesToCreate, nil).Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().CreateCategory(gomock.Any(), gomock.Any()).Times(0)
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().SaveCategory(expectedCategory).Return(nil).Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().CreateCategory(0, category.Name).Return(1, nil).Times(1)
err := createMissingCategories(piwigoMock, dbmock)
@ -288,7 +288,7 @@ func Test_SynchronizeCategories(t *testing.T) {
dbmock := NewMockCategoryProvider(mockCtrl)
dbmock.EXPECT().GetCategoriesToCreate().Times(1)
piwigoMock := NewMockPiwigoCategoryApi(mockCtrl)
piwigoMock := NewMockCategoryApi(mockCtrl)
piwigoMock.EXPECT().GetAllCategories().Times(1)
err := SynchronizeCategories(fileSystemNodes, piwigoMock, dbmock)

View File

@ -1,5 +1,5 @@
// 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
@ -10,31 +10,31 @@ import (
reflect "reflect"
)
// MockPiwigoCategoryApi is a mock of PiwigoCategoryApi interface
type MockPiwigoCategoryApi struct {
// MockCategoryApi is a mock of CategoryApi interface
type MockCategoryApi struct {
ctrl *gomock.Controller
recorder *MockPiwigoCategoryApiMockRecorder
recorder *MockCategoryApiMockRecorder
}
// MockPiwigoCategoryApiMockRecorder is the mock recorder for MockPiwigoCategoryApi
type MockPiwigoCategoryApiMockRecorder struct {
mock *MockPiwigoCategoryApi
// MockCategoryApiMockRecorder is the mock recorder for MockCategoryApi
type MockCategoryApiMockRecorder struct {
mock *MockCategoryApi
}
// NewMockPiwigoCategoryApi creates a new mock instance
func NewMockPiwigoCategoryApi(ctrl *gomock.Controller) *MockPiwigoCategoryApi {
mock := &MockPiwigoCategoryApi{ctrl: ctrl}
mock.recorder = &MockPiwigoCategoryApiMockRecorder{mock}
// NewMockCategoryApi creates a new mock instance
func NewMockCategoryApi(ctrl *gomock.Controller) *MockCategoryApi {
mock := &MockCategoryApi{ctrl: ctrl}
mock.recorder = &MockCategoryApiMockRecorder{mock}
return mock
}
// 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
}
// 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()
ret := m.ctrl.Call(m, "CreateCategory", arg0, arg1)
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
func (mr *MockPiwigoCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call {
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
func (m *MockPiwigoCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) {
func (m *MockCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllCategories")
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
func (mr *MockPiwigoCategoryApiMockRecorder) GetAllCategories() *gomock.Call {
func (mr *MockCategoryApiMockRecorder) GetAllCategories() *gomock.Call {
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
type MockPiwigoImageApi struct {
// MockImageApi is a mock of ImageApi interface
type MockImageApi struct {
ctrl *gomock.Controller
recorder *MockPiwigoImageApiMockRecorder
recorder *MockImageApiMockRecorder
}
// MockPiwigoImageApiMockRecorder is the mock recorder for MockPiwigoImageApi
type MockPiwigoImageApiMockRecorder struct {
mock *MockPiwigoImageApi
// MockImageApiMockRecorder is the mock recorder for MockImageApi
type MockImageApiMockRecorder struct {
mock *MockImageApi
}
// NewMockPiwigoImageApi creates a new mock instance
func NewMockPiwigoImageApi(ctrl *gomock.Controller) *MockPiwigoImageApi {
mock := &MockPiwigoImageApi{ctrl: ctrl}
mock.recorder = &MockPiwigoImageApiMockRecorder{mock}
// NewMockImageApi creates a new mock instance
func NewMockImageApi(ctrl *gomock.Controller) *MockImageApi {
mock := &MockImageApi{ctrl: ctrl}
mock.recorder = &MockImageApiMockRecorder{mock}
return mock
}
// 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
}
// DeleteImages mocks base method
func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error {
func (m *MockImageApi) DeleteImages(arg0 []int) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteImages", arg0)
ret0, _ := ret[0].(error)
@ -95,13 +95,13 @@ func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error {
}
// 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()
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
func (m *MockPiwigoImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) {
func (m *MockImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImageCheckFile", arg0, arg1)
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
func (mr *MockPiwigoImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call {
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
func (m *MockPiwigoImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) {
func (m *MockImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImagesExistOnPiwigo", arg0)
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
func (mr *MockPiwigoImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call {
func (mr *MockImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call {
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
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()
ret := m.ctrl.Call(m, "UploadImage", arg0, arg1, arg2, arg3)
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
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()
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"
)
func DeleteImages(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.ImageMetadataProvider) error {
func DeleteImages(piwigoCtx piwigo.ImageApi, metadataProvider datastore.ImageMetadataProvider) error {
logrus.Debug("Starting deleteImages")
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().DeleteMarkedImages().Times(1).Return(nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().DeleteImages([]int{5}).Times(1).Return(nil)
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().DeleteMarkedImages().Times(1).Return(nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().DeleteImages(gomock.Any()).Times(0)
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().DeleteMarkedImages().Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().DeleteImages(gomock.Any()).Times(0)
err := DeleteImages(piwigomock, dbmock)

View File

@ -1,5 +1,5 @@
// 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
@ -10,31 +10,31 @@ import (
reflect "reflect"
)
// MockPiwigoCategoryApi is a mock of PiwigoCategoryApi interface
type MockPiwigoCategoryApi struct {
// MockCategoryApi is a mock of CategoryApi interface
type MockCategoryApi struct {
ctrl *gomock.Controller
recorder *MockPiwigoCategoryApiMockRecorder
recorder *MockCategoryApiMockRecorder
}
// MockPiwigoCategoryApiMockRecorder is the mock recorder for MockPiwigoCategoryApi
type MockPiwigoCategoryApiMockRecorder struct {
mock *MockPiwigoCategoryApi
// MockCategoryApiMockRecorder is the mock recorder for MockCategoryApi
type MockCategoryApiMockRecorder struct {
mock *MockCategoryApi
}
// NewMockPiwigoCategoryApi creates a new mock instance
func NewMockPiwigoCategoryApi(ctrl *gomock.Controller) *MockPiwigoCategoryApi {
mock := &MockPiwigoCategoryApi{ctrl: ctrl}
mock.recorder = &MockPiwigoCategoryApiMockRecorder{mock}
// NewMockCategoryApi creates a new mock instance
func NewMockCategoryApi(ctrl *gomock.Controller) *MockCategoryApi {
mock := &MockCategoryApi{ctrl: ctrl}
mock.recorder = &MockCategoryApiMockRecorder{mock}
return mock
}
// 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
}
// 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()
ret := m.ctrl.Call(m, "CreateCategory", arg0, arg1)
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
func (mr *MockPiwigoCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockCategoryApiMockRecorder) CreateCategory(arg0, arg1 interface{}) *gomock.Call {
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
func (m *MockPiwigoCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) {
func (m *MockCategoryApi) GetAllCategories() (map[string]*piwigo.Category, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllCategories")
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
func (mr *MockPiwigoCategoryApiMockRecorder) GetAllCategories() *gomock.Call {
func (mr *MockCategoryApiMockRecorder) GetAllCategories() *gomock.Call {
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
type MockPiwigoImageApi struct {
// MockImageApi is a mock of ImageApi interface
type MockImageApi struct {
ctrl *gomock.Controller
recorder *MockPiwigoImageApiMockRecorder
recorder *MockImageApiMockRecorder
}
// MockPiwigoImageApiMockRecorder is the mock recorder for MockPiwigoImageApi
type MockPiwigoImageApiMockRecorder struct {
mock *MockPiwigoImageApi
// MockImageApiMockRecorder is the mock recorder for MockImageApi
type MockImageApiMockRecorder struct {
mock *MockImageApi
}
// NewMockPiwigoImageApi creates a new mock instance
func NewMockPiwigoImageApi(ctrl *gomock.Controller) *MockPiwigoImageApi {
mock := &MockPiwigoImageApi{ctrl: ctrl}
mock.recorder = &MockPiwigoImageApiMockRecorder{mock}
// NewMockImageApi creates a new mock instance
func NewMockImageApi(ctrl *gomock.Controller) *MockImageApi {
mock := &MockImageApi{ctrl: ctrl}
mock.recorder = &MockImageApiMockRecorder{mock}
return mock
}
// 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
}
// DeleteImages mocks base method
func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error {
func (m *MockImageApi) DeleteImages(arg0 []int) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteImages", arg0)
ret0, _ := ret[0].(error)
@ -95,13 +95,13 @@ func (m *MockPiwigoImageApi) DeleteImages(arg0 []int) error {
}
// 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()
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
func (m *MockPiwigoImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) {
func (m *MockImageApi) ImageCheckFile(arg0 int, arg1 string) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImageCheckFile", arg0, arg1)
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
func (mr *MockPiwigoImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockImageApiMockRecorder) ImageCheckFile(arg0, arg1 interface{}) *gomock.Call {
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
func (m *MockPiwigoImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) {
func (m *MockImageApi) ImagesExistOnPiwigo(arg0 []string) (map[string]int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImagesExistOnPiwigo", arg0)
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
func (mr *MockPiwigoImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call {
func (mr *MockImageApiMockRecorder) ImagesExistOnPiwigo(arg0 interface{}) *gomock.Call {
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
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()
ret := m.ctrl.Call(m, "UploadImage", arg0, arg1, arg2, arg3)
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
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()
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
//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
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.
func SynchronizePiwigoMetadata(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.ImageMetadataProvider) error {
func SynchronizePiwigoMetadata(piwigoCtx piwigo.ImageApi, metadataProvider datastore.ImageMetadataProvider) error {
logrus.Debug("Entering 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.
// 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...")
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.
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...")
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.EXPECT().ImageMetadataToUpload().Return(images, nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(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.EXPECT().ImageMetadataToUpload().Return(images, nil)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(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
dbmock.EXPECT().SaveImageMetadata(imgExpected).Times(1)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImageCheckFile(1, "1234").Return(piwigo.ImageStateUptodate, nil)
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().SaveImageMetadata(gomock.Any()).Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImageCheckFile(1, "1234").Return(piwigo.ImageStateDifferent, nil)
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().SavePiwigoIdAndUpdateUploadFlag(gomock.Any(), gomock.Any()).Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0)
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().SavePiwigoIdAndUpdateUploadFlag(gomock.Any(), gomock.Any()).Times(0)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(0)
err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock)
@ -165,7 +165,7 @@ func Test_updatePiwigoIdIfAlreadyUploaded_with_image_to_check(t *testing.T) {
piwigoResponose := make(map[string]int)
piwigoResponose["1234"] = 1
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(1).Return(piwigoResponose, nil)
err := updatePiwigoIdIfAlreadyUploaded(dbmock, piwigomock)
@ -192,7 +192,7 @@ func Test_updatePiwigoIdIfAlreadyUploaded_with_image_to_check_missing_on_server(
piwigoResponose := make(map[string]int)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().ImagesExistOnPiwigo(gomock.Any()).Times(1).Return(piwigoResponose, nil)
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.
// 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")
defer logrus.Debug("Finished uploadImages successfully")
@ -51,7 +51,7 @@ func UploadImages(piwigoCtx piwigo.PiwigoImageApi, metadataProvider datastore.Im
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 {
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().SaveImageMetadata(imgToSave).Times(1)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().UploadImage(0, "/nonexisting/file.jpg", "1234", 2).Times(1).Return(5, nil)
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().SaveImageMetadata(imgToSave).Times(1)
piwigomock := NewMockPiwigoImageApi(mockCtrl)
piwigomock := NewMockImageApi(mockCtrl)
piwigomock.EXPECT().UploadImage(5, "/nonexisting/file.jpg", "1234", 2).Times(1).Return(5, nil)
err := UploadImages(piwigomock, dbmock, 1)

View File

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