diff --git a/backend/app/store/engine/engine.go b/backend/app/store/engine/engine.go index df8c30c3..8644a0ee 100644 --- a/backend/app/store/engine/engine.go +++ b/backend/app/store/engine/engine.go @@ -11,8 +11,8 @@ import ( "github.com/umputun/remark42/backend/app/store" ) -// NOTE: mockery works from linked to go-path and with go generate -//go:generate sh -c "mockery -inpkg -name Interface -print > /tmp/engine-mock.tmp && mv /tmp/engine-mock.tmp engine_mock.go" +// NOTE: mockery should be installed globally and works with `go generate ./...` +//go:generate mockery --inpackage --name Interface --filename engine_mock.go // Interface defines methods provided by low-level storage engine type Interface interface { diff --git a/backend/app/store/engine/engine_mock.go b/backend/app/store/engine/engine_mock.go index 5fda9baf..170fe3a3 100644 --- a/backend/app/store/engine/engine_mock.go +++ b/backend/app/store/engine/engine_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v1.1.2. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package engine @@ -229,3 +229,18 @@ func (_m *MockInterface) UserDetail(req UserDetailRequest) ([]UserDetailEntry, e return r0, r1 } + +type mockConstructorTestingTNewMockInterface interface { + mock.TestingT + Cleanup(func()) +} + +// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockInterface(t mockConstructorTestingTNewMockInterface) *MockInterface { + mock := &MockInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/backend/app/store/image/image.go b/backend/app/store/image/image.go index aae6f4de..6cf4fb2e 100644 --- a/backend/app/store/image/image.go +++ b/backend/app/store/image/image.go @@ -3,7 +3,8 @@ // Service object encloses Store and add common methods, this is the one consumer should use. package image -//go:generate sh -c "mockery -inpkg -name Store -print > /tmp/mock.tmp && mv /tmp/mock.tmp image_mock.go" +// NOTE: mockery should be installed globally and works with `go generate ./...` +//go:generate mockery --inpackage --name Store --filename image_mock.go import ( "bytes" @@ -61,9 +62,6 @@ type StoreInfo struct { FirstStagingImageTS time.Time } -// To regenerate mock run from this directory: -// sh -c "mockery -inpkg -name Store -print > /tmp/image-mock.tmp && mv /tmp/image-mock.tmp image_mock.go" - // Store defines interface for saving and loading pictures. // Declares two-stage save with Commit. Save stores to staging area and Commit moves to the final location. // Two-stage commit scheme is used for not storing images which are uploaded but later never used in the comments, @@ -367,7 +365,7 @@ func Sha1Str(s string) string { // ID would look like: "cached_images/-" // - would allow us to identify all images from particular site if ever needed // - would allow us to avoid storing duplicates of the same image -// (as accurate as deduplication based on potentially mutable url can be) +// (as accurate as deduplication based on potentially mutable url can be) func CachedImgID(imgURL string) (string, error) { parsedURL, err := url.Parse(imgURL) if err != nil { diff --git a/backend/app/store/image/image_mock.go b/backend/app/store/image/image_mock.go index fc7e6e54..d7f08205 100644 --- a/backend/app/store/image/image_mock.go +++ b/backend/app/store/image/image_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v1.1.2. DO NOT EDIT. +// Code generated by mockery v2.14.0. DO NOT EDIT. package image @@ -113,3 +113,18 @@ func (_m *MockStore) Save(id string, img []byte) error { return r0 } + +type mockConstructorTestingTNewMockStore interface { + mock.TestingT + Cleanup(func()) +} + +// NewMockStore creates a new instance of MockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockStore(t mockConstructorTestingTNewMockStore) *MockStore { + mock := &MockStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}