drone/registry/app/api/controller/mocks/artifact_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

371 lines
13 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"
)
// ArtifactRepository is an autogenerated mock type for the ArtifactRepository type
type ArtifactRepository struct {
mock.Mock
}
// Count provides a mock function with given fields: ctx
func (_m *ArtifactRepository) Count(ctx context.Context) (int64, error) {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Count")
}
var r0 int64
var r1 error
if rf, ok := ret.Get(0).(func(context.Context) (int64, error)); ok {
return rf(ctx)
}
if rf, ok := ret.Get(0).(func(context.Context) int64); ok {
r0 = rf(ctx)
} else {
r0 = ret.Get(0).(int64)
}
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
r1 = rf(ctx)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CountAllArtifactsByParentID provides a mock function with given fields: ctx, parentID, registryIDs, search, latestVersion, packageTypes
func (_m *ArtifactRepository) CountAllArtifactsByParentID(ctx context.Context, parentID int64, registryIDs *[]string, search string, latestVersion bool, packageTypes []string) (int64, error) {
ret := _m.Called(ctx, parentID, registryIDs, search, latestVersion, packageTypes)
if len(ret) == 0 {
panic("no return value specified for CountAllArtifactsByParentID")
}
var r0 int64
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, *[]string, string, bool, []string) (int64, error)); ok {
return rf(ctx, parentID, registryIDs, search, latestVersion, packageTypes)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, *[]string, string, bool, []string) int64); ok {
r0 = rf(ctx, parentID, registryIDs, search, latestVersion, packageTypes)
} else {
r0 = ret.Get(0).(int64)
}
if rf, ok := ret.Get(1).(func(context.Context, int64, *[]string, string, bool, []string) error); ok {
r1 = rf(ctx, parentID, registryIDs, search, latestVersion, packageTypes)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CountAllArtifactsByRepo provides a mock function with given fields: ctx, parentID, repoKey, search, labels
func (_m *ArtifactRepository) CountAllArtifactsByRepo(ctx context.Context, parentID int64, repoKey string, search string, labels []string) (int64, error) {
ret := _m.Called(ctx, parentID, repoKey, search, labels)
if len(ret) == 0 {
panic("no return value specified for CountAllArtifactsByRepo")
}
var r0 int64
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, []string) (int64, error)); ok {
return rf(ctx, parentID, repoKey, search, labels)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, []string) int64); ok {
r0 = rf(ctx, parentID, repoKey, search, labels)
} else {
r0 = ret.Get(0).(int64)
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string, []string) error); ok {
r1 = rf(ctx, parentID, repoKey, search, labels)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CountAllVersionsByRepoAndImage provides a mock function with given fields: ctx, parentID, repoKey, image, search
func (_m *ArtifactRepository) CountAllVersionsByRepoAndImage(ctx context.Context, parentID int64, repoKey string, image string, search string) (int64, error) {
ret := _m.Called(ctx, parentID, repoKey, image, search)
if len(ret) == 0 {
panic("no return value specified for CountAllVersionsByRepoAndImage")
}
var r0 int64
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string) (int64, error)); ok {
return rf(ctx, parentID, repoKey, image, search)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string) int64); ok {
r0 = rf(ctx, parentID, repoKey, image, search)
} else {
r0 = ret.Get(0).(int64)
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string, string) error); ok {
r1 = rf(ctx, parentID, repoKey, image, search)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CreateOrUpdate provides a mock function with given fields: ctx, artifact
func (_m *ArtifactRepository) CreateOrUpdate(ctx context.Context, artifact *types.Artifact) error {
ret := _m.Called(ctx, artifact)
if len(ret) == 0 {
panic("no return value specified for CreateOrUpdate")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *types.Artifact) error); ok {
r0 = rf(ctx, artifact)
} else {
r0 = ret.Error(0)
}
return r0
}
// GetAllArtifactsByParentID provides a mock function with given fields: ctx, id, i, field, order, limit, offset, term, version, packageTypes
func (_m *ArtifactRepository) GetAllArtifactsByParentID(ctx context.Context, id int64, i *[]string, field string, order string, limit int, offset int, term string, version bool, packageTypes []string) (*[]types.ArtifactMetadata, error) {
ret := _m.Called(ctx, id, i, field, order, limit, offset, term, version, packageTypes)
if len(ret) == 0 {
panic("no return value specified for GetAllArtifactsByParentID")
}
var r0 *[]types.ArtifactMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, *[]string, string, string, int, int, string, bool, []string) (*[]types.ArtifactMetadata, error)); ok {
return rf(ctx, id, i, field, order, limit, offset, term, version, packageTypes)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, *[]string, string, string, int, int, string, bool, []string) *[]types.ArtifactMetadata); ok {
r0 = rf(ctx, id, i, field, order, limit, offset, term, version, packageTypes)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*[]types.ArtifactMetadata)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, *[]string, string, string, int, int, string, bool, []string) error); ok {
r1 = rf(ctx, id, i, field, order, limit, offset, term, version, packageTypes)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetAllArtifactsByRepo provides a mock function with given fields: ctx, parentID, repoKey, sortByField, sortByOrder, limit, offset, search, labels
func (_m *ArtifactRepository) GetAllArtifactsByRepo(ctx context.Context, parentID int64, repoKey string, sortByField string, sortByOrder string, limit int, offset int, search string, labels []string) (*[]types.ArtifactMetadata, error) {
ret := _m.Called(ctx, parentID, repoKey, sortByField, sortByOrder, limit, offset, search, labels)
if len(ret) == 0 {
panic("no return value specified for GetAllArtifactsByRepo")
}
var r0 *[]types.ArtifactMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string, int, int, string, []string) (*[]types.ArtifactMetadata, error)); ok {
return rf(ctx, parentID, repoKey, sortByField, sortByOrder, limit, offset, search, labels)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string, int, int, string, []string) *[]types.ArtifactMetadata); ok {
r0 = rf(ctx, parentID, repoKey, sortByField, sortByOrder, limit, offset, search, labels)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*[]types.ArtifactMetadata)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string, string, int, int, string, []string) error); ok {
r1 = rf(ctx, parentID, repoKey, sortByField, sortByOrder, limit, offset, search, labels)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetAllVersionsByRepoAndImage provides a mock function with given fields: ctx, id, identifier, image, field, order, limit, offset, term
func (_m *ArtifactRepository) GetAllVersionsByRepoAndImage(ctx context.Context, id int64, identifier string, image string, field string, order string, limit int, offset int, term string) (*[]types.NonOCIArtifactMetadata, error) {
ret := _m.Called(ctx, id, identifier, image, field, order, limit, offset, term)
if len(ret) == 0 {
panic("no return value specified for GetAllVersionsByRepoAndImage")
}
var r0 *[]types.NonOCIArtifactMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string, string, int, int, string) (*[]types.NonOCIArtifactMetadata, error)); ok {
return rf(ctx, id, identifier, image, field, order, limit, offset, term)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string, string, int, int, string) *[]types.NonOCIArtifactMetadata); ok {
r0 = rf(ctx, id, identifier, image, field, order, limit, offset, term)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*[]types.NonOCIArtifactMetadata)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string, string, string, int, int, string) error); ok {
r1 = rf(ctx, id, identifier, image, field, order, limit, offset, term)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetArtifactMetadata provides a mock function with given fields: ctx, id, identifier, image, version
func (_m *ArtifactRepository) GetArtifactMetadata(ctx context.Context, id int64, identifier string, image string, version string) (*types.ArtifactMetadata, error) {
ret := _m.Called(ctx, id, identifier, image, version)
if len(ret) == 0 {
panic("no return value specified for GetArtifactMetadata")
}
var r0 *types.ArtifactMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string) (*types.ArtifactMetadata, error)); ok {
return rf(ctx, id, identifier, image, version)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string, string) *types.ArtifactMetadata); ok {
r0 = rf(ctx, id, identifier, image, version)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.ArtifactMetadata)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string, string) error); ok {
r1 = rf(ctx, id, identifier, image, version)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetByName provides a mock function with given fields: ctx, imageID, version
func (_m *ArtifactRepository) GetByName(ctx context.Context, imageID int64, version string) (*types.Artifact, error) {
ret := _m.Called(ctx, imageID, version)
if len(ret) == 0 {
panic("no return value specified for GetByName")
}
var r0 *types.Artifact
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*types.Artifact, error)); ok {
return rf(ctx, imageID, version)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string) *types.Artifact); ok {
r0 = rf(ctx, imageID, version)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.Artifact)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok {
r1 = rf(ctx, imageID, version)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetByRegistryIDAndImage provides a mock function with given fields: ctx, registryID, image
func (_m *ArtifactRepository) GetByRegistryIDAndImage(ctx context.Context, registryID int64, image string) (*[]types.Artifact, error) {
ret := _m.Called(ctx, registryID, image)
if len(ret) == 0 {
panic("no return value specified for GetByRegistryIDAndImage")
}
var r0 *[]types.Artifact
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*[]types.Artifact, error)); ok {
return rf(ctx, registryID, image)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string) *[]types.Artifact); ok {
r0 = rf(ctx, registryID, image)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*[]types.Artifact)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok {
r1 = rf(ctx, registryID, image)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetLatestArtifactMetadata provides a mock function with given fields: ctx, id, identifier, image
func (_m *ArtifactRepository) GetLatestArtifactMetadata(ctx context.Context, id int64, identifier string, image string) (*types.ArtifactMetadata, error) {
ret := _m.Called(ctx, id, identifier, image)
if len(ret) == 0 {
panic("no return value specified for GetLatestArtifactMetadata")
}
var r0 *types.ArtifactMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string) (*types.ArtifactMetadata, error)); ok {
return rf(ctx, id, identifier, image)
}
if rf, ok := ret.Get(0).(func(context.Context, int64, string, string) *types.ArtifactMetadata); ok {
r0 = rf(ctx, id, identifier, image)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.ArtifactMetadata)
}
}
if rf, ok := ret.Get(1).(func(context.Context, int64, string, string) error); ok {
r1 = rf(ctx, id, identifier, image)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// NewArtifactRepository creates a new instance of ArtifactRepository. 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 NewArtifactRepository(t interface {
mock.TestingT
Cleanup(func())
}) *ArtifactRepository {
mock := &ArtifactRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}