drone/registry/app/api/controller/mocks/image_repository.go
Manjunatha EN a73113f8e6 fix: [AH-771]: gitness unit test refactoring (#3589)
* fix merge conflicts
* fix merge conflicts
* fix review comment
* fix review comment
* fix review comment
* fix: [AH-771]: gitness unit test refactoring
* fix: [AH-771]: resolved review comments
* fix: [AH-771]: resolved review comments
* fix: [AH-771] Registry test refactoring and improvements

- Refactored registry metadata test implementations
- Improved code organization and readability
- Fixed line length issues in test files
- Removed unused fields from request.go
- Added proper license headers
- Fixed linting issues in mock files
- Simplified test setup and assertions
- Updated wire generation for cmd package
- Added nolint:exhaustive directive for package type switch

fix: [AH-771] Registry test refactoring and improvements

- Refactored registry metadata test implementations
- Improved code organization and readability
- Fixed line length issues in test files
- Removed unused fields from request.go
- Added proper license headers
- Fixed linting issues in mock files
- Simplifi
2025-04-22 14:49:24 +00:00

323 lines
8.7 KiB
Go

// Code generated by mockery v2.53.3. DO NOT EDIT.
package mocks
import (
context "context"
types "github.com/harness/gitness/registry/types"
mock "github.com/stretchr/testify/mock"
)
// ImageRepository is an autogenerated mock type for the ImageRepository type
type ImageRepository struct {
mock.Mock
}
// CountLabelsByParentIDAndRepo provides a mock function with given fields: ctx, parentID, repo, search
func (_m *ImageRepository) CountLabelsByParentIDAndRepo(ctx context.Context, parentID int64, repo string, search string) (int64, error) {
ret := _m.Called(ctx, parentID, repo, search)
if len(ret) == 0 {
panic("no return value specified for CountLabelsByParentIDAndRepo")
}
var r0 int64
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string) (int64, error)); ok {
return rf(ctx, parentID, repo, search)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string) int64); ok {
r0 = rf(ctx, parentID, repo, search)
} else {
r0 = ret.Get(0).(int64)
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string) error); ok {
r1 = rf(ctx, parentID, repo, search)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CreateOrUpdate provides a mock function with given fields: ctx, image
func (_m *ImageRepository) CreateOrUpdate(ctx context.Context, image *types.Image) error {
ret := _m.Called(ctx, image)
if len(ret) == 0 {
panic("no return value specified for CreateOrUpdate")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *types.Image) error); ok {
r0 = rf(ctx, image)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteBandwidthStatByRegistryID provides a mock function with given fields: ctx, registryID
func (_m *ImageRepository) DeleteBandwidthStatByRegistryID(ctx context.Context, registryID int64) error {
ret := _m.Called(ctx, registryID)
if len(ret) == 0 {
panic("no return value specified for DeleteBandwidthStatByRegistryID")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
r0 = rf(ctx, registryID)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteByRegistryID provides a mock function with given fields: ctx, registryID
func (_m *ImageRepository) DeleteByRegistryID(ctx context.Context, registryID int64) error {
ret := _m.Called(ctx, registryID)
if len(ret) == 0 {
panic("no return value specified for DeleteByRegistryID")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
r0 = rf(ctx, registryID)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteDownloadStatByRegistryID provides a mock function with given fields: ctx, registryID
func (_m *ImageRepository) DeleteDownloadStatByRegistryID(ctx context.Context, registryID int64) error {
ret := _m.Called(ctx, registryID)
if len(ret) == 0 {
panic("no return value specified for DeleteDownloadStatByRegistryID")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
r0 = rf(ctx, registryID)
} else {
r0 = ret.Error(0)
}
return r0
}
// Get provides a mock function with given fields: ctx, id
func (_m *ImageRepository) Get(ctx context.Context, id int64) (*types.Image, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for Get")
}
var r0 *types.Image
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64) (*types.Image, error)); ok {
return rf(ctx, id)
}
if rf, ok := ret.Get(0).(func(context.Context, int64) *types.Image); ok {
r0 = rf(ctx, id)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.Image)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
r1 = rf(ctx, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetByName provides a mock function with given fields: ctx, registryID, name
func (_m *ImageRepository) GetByName(ctx context.Context, registryID int64, name string) (*types.Image, error) {
ret := _m.Called(ctx, registryID, name)
if len(ret) == 0 {
panic("no return value specified for GetByName")
}
var r0 *types.Image
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*types.Image, error)); ok {
return rf(ctx, registryID, name)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string) *types.Image); ok {
r0 = rf(ctx, registryID, name)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.Image)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok {
r1 = rf(ctx, registryID, name)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetByRepoAndName provides a mock function with given fields: ctx, parentID, repo, name
func (_m *ImageRepository) GetByRepoAndName(ctx context.Context, parentID int64, repo string, name string) (*types.Image, error) {
ret := _m.Called(ctx, parentID, repo, name)
if len(ret) == 0 {
panic("no return value specified for GetByRepoAndName")
}
var r0 *types.Image
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string) (*types.Image, error)); ok {
return rf(ctx, parentID, repo, name)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string) *types.Image); ok {
r0 = rf(ctx, parentID, repo, name)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.Image)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string) error); ok {
r1 = rf(ctx, parentID, repo, name)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetLabelsByParentIDAndRepo provides a mock function with given fields: ctx, parentID, repo, limit, offset, search
func (_m *ImageRepository) GetLabelsByParentIDAndRepo(ctx context.Context, parentID int64, repo string, limit int, offset int, search string) ([]string, error) {
ret := _m.Called(ctx, parentID, repo, limit, offset, search)
if len(ret) == 0 {
panic("no return value specified for GetLabelsByParentIDAndRepo")
}
var r0 []string
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, int, int, string) ([]string, error)); ok {
return rf(ctx, parentID, repo, limit, offset, search)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, int, int, string) []string); ok {
r0 = rf(ctx, parentID, repo, limit, offset, search)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]string)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, int, int, string) error); ok {
r1 = rf(ctx, parentID, repo, limit, offset, search)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Update provides a mock function with given fields: ctx, artifact
func (_m *ImageRepository) Update(ctx context.Context, artifact *types.Image) error {
ret := _m.Called(ctx, artifact)
if len(ret) == 0 {
panic("no return value specified for Update")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *types.Image) error); ok {
r0 = rf(ctx, artifact)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateStatus provides a mock function with given fields: ctx, artifact
func (_m *ImageRepository) UpdateStatus(ctx context.Context, artifact *types.Image) error {
ret := _m.Called(ctx, artifact)
if len(ret) == 0 {
panic("no return value specified for UpdateStatus")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *types.Image) error); ok {
r0 = rf(ctx, artifact)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteByImageNameAndRegID provides a mock function with given fields: ctx, regID, image
func (_m *ImageRepository) DeleteByImageNameAndRegID(ctx context.Context, regID int64, image string) error {
ret := _m.Called(ctx, regID, image)
if len(ret) == 0 {
panic("no return value specified for DeleteByImageNameAndRegID")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok {
r0 = rf(ctx, regID, image)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteByImageNameIfNoLinkedArtifacts provides a mock function with given fields: ctx, regID, image
func (_m *ImageRepository) DeleteByImageNameIfNoLinkedArtifacts(ctx context.Context, regID int64, image string) error {
ret := _m.Called(ctx, regID, image)
if len(ret) == 0 {
panic("no return value specified for DeleteByImageNameIfNoLinkedArtifacts")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok {
r0 = rf(ctx, regID, image)
} else {
r0 = ret.Error(0)
}
return r0
}
// NewImageRepository creates a new instance of ImageRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewImageRepository(t interface {
mock.TestingT
Cleanup(func())
}) *ImageRepository {
mock := &ImageRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}