mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-25 03:35:21 +01:00
refactor: unify the mock file generation (#20765)
1. Mock remote interface for distribution manifest by mockery package feature. 2. Refactor hand-generated mock files to automated management generation. 3. Clean useless mocks. Signed-off-by: chlins <chlins.zhang@gmail.com>
This commit is contained in:
parent
295e075568
commit
5deedf4c7c
@ -9,6 +9,17 @@ packages:
|
||||
Controller:
|
||||
config:
|
||||
dir: testing/controller/artifact
|
||||
github.com/goharbor/harbor/src/controller/artifact/processor:
|
||||
interfaces:
|
||||
Processor:
|
||||
config:
|
||||
dir: testing/pkg/processor
|
||||
github.com/goharbor/harbor/src/controller/artifact/annotation:
|
||||
interfaces:
|
||||
Parser:
|
||||
config:
|
||||
dir: testing/pkg/parser
|
||||
outpkg: parser
|
||||
github.com/goharbor/harbor/src/controller/blob:
|
||||
interfaces:
|
||||
Controller:
|
||||
@ -188,6 +199,11 @@ packages:
|
||||
Manager:
|
||||
config:
|
||||
dir: testing/pkg/artifact
|
||||
github.com/goharbor/harbor/src/pkg/artifactrash:
|
||||
interfaces:
|
||||
Manager:
|
||||
config:
|
||||
dir: testing/pkg/artifactrash
|
||||
github.com/goharbor/harbor/src/pkg/blob:
|
||||
interfaces:
|
||||
Manager:
|
||||
@ -218,6 +234,11 @@ packages:
|
||||
Handler:
|
||||
config:
|
||||
dir: testing/pkg/scan
|
||||
github.com/goharbor/harbor/src/pkg/scan/postprocessors:
|
||||
interfaces:
|
||||
NativeScanReportConverter:
|
||||
config:
|
||||
dir: testing/pkg/scan/postprocessors
|
||||
github.com/goharbor/harbor/src/pkg/scan/report:
|
||||
interfaces:
|
||||
Manager:
|
||||
@ -342,6 +363,14 @@ packages:
|
||||
DAO:
|
||||
config:
|
||||
dir: testing/pkg/immutable/dao
|
||||
github.com/goharbor/harbor/src/pkg/immutable/match:
|
||||
interfaces:
|
||||
ImmutableTagMatcher:
|
||||
config:
|
||||
dir: testing/pkg/immutable
|
||||
filename: matcher.go
|
||||
outpkg: immutable
|
||||
mockname: FakeMatcher
|
||||
github.com/goharbor/harbor/src/pkg/ldap:
|
||||
interfaces:
|
||||
Manager:
|
||||
@ -505,20 +534,36 @@ packages:
|
||||
Manager:
|
||||
config:
|
||||
dir: testing/pkg/securityhub
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
github.com/goharbor/harbor/src/pkg/tag:
|
||||
interfaces:
|
||||
Manager:
|
||||
config:
|
||||
dir: testing/pkg/tag
|
||||
github.com/goharbor/harbor/src/pkg/p2p/preheat/policy:
|
||||
interfaces:
|
||||
Manager:
|
||||
config:
|
||||
dir: testing/pkg/p2p/preheat/policy
|
||||
github.com/goharbor/harbor/src/pkg/p2p/preheat/instance:
|
||||
interfaces:
|
||||
Manager:
|
||||
config:
|
||||
dir: testing/pkg/p2p/preheat/instance
|
||||
github.com/goharbor/harbor/src/pkg/chart:
|
||||
interfaces:
|
||||
Operator:
|
||||
config:
|
||||
dir: testing/pkg/chart
|
||||
# registryctl related mocks
|
||||
github.com/goharbor/harbor/src/registryctl/client:
|
||||
interfaces:
|
||||
Client:
|
||||
config:
|
||||
dir: testing/registryctl
|
||||
outpkg: registryctl
|
||||
# remote interfaces
|
||||
github.com/docker/distribution:
|
||||
interfaces:
|
||||
Manifest:
|
||||
config:
|
||||
dir: testing/pkg/distribution
|
||||
|
@ -67,7 +67,7 @@ type controllerTestSuite struct {
|
||||
ctl *controller
|
||||
repoMgr *repotesting.Manager
|
||||
artMgr *arttesting.Manager
|
||||
artrashMgr *artrashtesting.FakeManager
|
||||
artrashMgr *artrashtesting.Manager
|
||||
blobMgr *blob.Manager
|
||||
tagCtl *tagtesting.FakeController
|
||||
labelMgr *label.Manager
|
||||
@ -80,7 +80,7 @@ type controllerTestSuite struct {
|
||||
func (c *controllerTestSuite) SetupTest() {
|
||||
c.repoMgr = &repotesting.Manager{}
|
||||
c.artMgr = &arttesting.Manager{}
|
||||
c.artrashMgr = &artrashtesting.FakeManager{}
|
||||
c.artrashMgr = &artrashtesting.Manager{}
|
||||
c.blobMgr = &blob.Manager{}
|
||||
c.tagCtl = &tagtesting.FakeController{}
|
||||
c.labelMgr = &label.Manager{}
|
||||
@ -476,7 +476,7 @@ func (c *controllerTestSuite) TestDeleteDeeply() {
|
||||
},
|
||||
}, nil)
|
||||
c.repoMgr.On("Get", mock.Anything, mock.Anything).Return(&repomodel.RepoRecord{}, nil)
|
||||
c.artrashMgr.On("Create").Return(0, nil)
|
||||
c.artrashMgr.On("Create", mock.Anything, mock.Anything).Return(int64(0), nil)
|
||||
c.accMgr.On("List", mock.Anything, mock.Anything).Return([]accessorymodel.Accessory{}, nil)
|
||||
err = c.ctl.deleteDeeply(orm.NewContext(nil, &ormtesting.FakeOrmer{}), 1, false, false)
|
||||
c.Require().Nil(err)
|
||||
@ -534,7 +534,7 @@ func (c *controllerTestSuite) TestDeleteDeeply() {
|
||||
c.blobMgr.On("List", mock.Anything, mock.Anything).Return(nil, nil)
|
||||
c.blobMgr.On("CleanupAssociationsForProject", mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
||||
c.repoMgr.On("Get", mock.Anything, mock.Anything).Return(&repomodel.RepoRecord{}, nil)
|
||||
c.artrashMgr.On("Create").Return(0, nil)
|
||||
c.artrashMgr.On("Create", mock.Anything, mock.Anything).Return(int64(0), nil)
|
||||
err = c.ctl.deleteDeeply(orm.NewContext(nil, &ormtesting.FakeOrmer{}), 1, true, true)
|
||||
c.Require().Nil(err)
|
||||
|
||||
|
@ -64,12 +64,12 @@ type processorTestSuite struct {
|
||||
suite.Suite
|
||||
processor *processor
|
||||
regCli *registry.Client
|
||||
chartOptr *chart.FakeOpertaor
|
||||
chartOptr *chart.Operator
|
||||
}
|
||||
|
||||
func (p *processorTestSuite) SetupTest() {
|
||||
p.regCli = ®istry.Client{}
|
||||
p.chartOptr = &chart.FakeOpertaor{}
|
||||
p.chartOptr = &chart.Operator{}
|
||||
p.processor = &processor{
|
||||
chartOperator: p.chartOptr,
|
||||
}
|
||||
@ -106,7 +106,7 @@ func (p *processorTestSuite) TestAbstractAddition() {
|
||||
p.Require().Nil(err)
|
||||
p.regCli.On("PullManifest", mock.Anything, mock.Anything).Return(manifest, "", nil)
|
||||
p.regCli.On("PullBlob", mock.Anything, mock.Anything).Return(int64(0), io.NopCloser(strings.NewReader(chartYaml)), nil)
|
||||
p.chartOptr.On("GetDetails").Return(chartDetails, nil)
|
||||
p.chartOptr.On("GetDetails", mock.Anything).Return(chartDetails, nil)
|
||||
|
||||
// values.yaml
|
||||
addition, err := p.processor.AbstractAddition(nil, artifact, AdditionTypeValues)
|
||||
|
@ -31,8 +31,8 @@ type preheatSuite struct {
|
||||
suite.Suite
|
||||
ctx context.Context
|
||||
controller Controller
|
||||
fakeInstanceMgr *instance.FakeManager
|
||||
fakePolicyMgr *pmocks.FakeManager
|
||||
fakeInstanceMgr *instance.Manager
|
||||
fakePolicyMgr *pmocks.Manager
|
||||
fakeScheduler *smocks.Scheduler
|
||||
mockInstanceServer *httptest.Server
|
||||
fakeExecutionMgr *tmocks.ExecutionManager
|
||||
@ -40,8 +40,8 @@ type preheatSuite struct {
|
||||
|
||||
func TestPreheatSuite(t *testing.T) {
|
||||
t.Log("Start TestPreheatSuite")
|
||||
fakeInstanceMgr := &instance.FakeManager{}
|
||||
fakePolicyMgr := &pmocks.FakeManager{}
|
||||
fakeInstanceMgr := &instance.Manager{}
|
||||
fakePolicyMgr := &pmocks.Manager{}
|
||||
fakeScheduler := &smocks.Scheduler{}
|
||||
fakeExecutionMgr := &tmocks.ExecutionManager{}
|
||||
|
||||
|
@ -70,7 +70,7 @@ func (suite *EnforcerTestSuite) SetupSuite() {
|
||||
suite.server.StartTLS()
|
||||
|
||||
fakePolicies := mockPolicies()
|
||||
fakePolicyManager := &policy.FakeManager{}
|
||||
fakePolicyManager := &policy.Manager{}
|
||||
fakePolicyManager.On("Get",
|
||||
context.TODO(),
|
||||
mock.AnythingOfType("int64")).
|
||||
@ -130,7 +130,7 @@ func (suite *EnforcerTestSuite) SetupSuite() {
|
||||
},
|
||||
}, nil)
|
||||
|
||||
fakeInstanceMgr := &instance.FakeManager{}
|
||||
fakeInstanceMgr := &instance.Manager{}
|
||||
fakeInstanceMgr.On("Get",
|
||||
context.TODO(),
|
||||
mock.AnythingOfType("int64"),
|
||||
|
@ -82,7 +82,7 @@ type ControllerTestSuite struct {
|
||||
reportMgr *reporttesting.Manager
|
||||
ar artifact.Controller
|
||||
c *basicController
|
||||
reportConverter *postprocessorstesting.ScanReportV1ToV2Converter
|
||||
reportConverter *postprocessorstesting.NativeScanReportConverter
|
||||
cache *mockcache.Cache
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ func (suite *ControllerTestSuite) SetupSuite() {
|
||||
|
||||
execMgr: suite.execMgr,
|
||||
taskMgr: suite.taskMgr,
|
||||
reportConverter: &postprocessorstesting.ScanReportV1ToV2Converter{},
|
||||
reportConverter: &postprocessorstesting.NativeScanReportConverter{},
|
||||
cache: func() cache.Cache { return suite.cache },
|
||||
}
|
||||
mock.OnAnything(suite.scanHandler, "JobVendorType").Return("IMAGE_SCAN")
|
||||
@ -486,6 +486,7 @@ func (suite *ControllerTestSuite) TestScanControllerGetReport() {
|
||||
{ExtraAttrs: suite.makeExtraAttrs(int64(1), "rp-uuid-001")},
|
||||
}, nil).Once()
|
||||
mock.OnAnything(suite.accessoryMgr, "List").Return(nil, nil)
|
||||
mock.OnAnything(suite.c.reportConverter, "FromRelationalSchema").Return("", nil)
|
||||
rep, err := suite.c.GetReport(ctx, suite.artifact, []string{v1.MimeTypeNativeReport})
|
||||
require.NoError(suite.T(), err)
|
||||
assert.Equal(suite.T(), 1, len(rep))
|
||||
|
@ -51,7 +51,7 @@ type CallbackTestSuite struct {
|
||||
scanCtl Controller
|
||||
|
||||
taskMgr *tasktesting.Manager
|
||||
reportConverter *postprocessorstesting.ScanReportV1ToV2Converter
|
||||
reportConverter *postprocessorstesting.NativeScanReportConverter
|
||||
}
|
||||
|
||||
func (suite *CallbackTestSuite) SetupSuite() {
|
||||
@ -69,7 +69,7 @@ func (suite *CallbackTestSuite) SetupSuite() {
|
||||
suite.taskMgr = &tasktesting.Manager{}
|
||||
taskMgr = suite.taskMgr
|
||||
|
||||
suite.reportConverter = &postprocessorstesting.ScanReportV1ToV2Converter{}
|
||||
suite.reportConverter = &postprocessorstesting.NativeScanReportConverter{}
|
||||
|
||||
suite.scanCtl = &basicController{
|
||||
makeCtx: context.TODO,
|
||||
|
@ -44,7 +44,7 @@ type ControllerTestSuite struct {
|
||||
c *controller
|
||||
scannerMgr *scannerMock.Manager
|
||||
secHubMgr *securityMock.Manager
|
||||
tagMgr *tagMock.FakeManager
|
||||
tagMgr *tagMock.Manager
|
||||
}
|
||||
|
||||
// TestController is the entry of controller test suite
|
||||
@ -56,7 +56,7 @@ func TestController(t *testing.T) {
|
||||
func (suite *ControllerTestSuite) SetupTest() {
|
||||
suite.secHubMgr = &securityMock.Manager{}
|
||||
suite.scannerMgr = &scannerMock.Manager{}
|
||||
suite.tagMgr = &tagMock.FakeManager{}
|
||||
suite.tagMgr = &tagMock.Manager{}
|
||||
|
||||
suite.c = &controller{
|
||||
secHubMgr: suite.secHubMgr,
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
@ -27,6 +26,7 @@ import (
|
||||
_ "github.com/goharbor/harbor/src/pkg/config/inmemory"
|
||||
"github.com/goharbor/harbor/src/pkg/tag/model/tag"
|
||||
ormtesting "github.com/goharbor/harbor/src/testing/lib/orm"
|
||||
"github.com/goharbor/harbor/src/testing/mock"
|
||||
"github.com/goharbor/harbor/src/testing/pkg/artifact"
|
||||
"github.com/goharbor/harbor/src/testing/pkg/immutable"
|
||||
"github.com/goharbor/harbor/src/testing/pkg/repository"
|
||||
@ -38,14 +38,14 @@ type controllerTestSuite struct {
|
||||
ctl *controller
|
||||
repoMgr *repository.Manager
|
||||
artMgr *artifact.Manager
|
||||
tagMgr *tagtesting.FakeManager
|
||||
tagMgr *tagtesting.Manager
|
||||
immutableMtr *immutable.FakeMatcher
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) SetupTest() {
|
||||
c.repoMgr = &repository.Manager{}
|
||||
c.artMgr = &artifact.Manager{}
|
||||
c.tagMgr = &tagtesting.FakeManager{}
|
||||
c.tagMgr = &tagtesting.Manager{}
|
||||
c.immutableMtr = &immutable.FakeMatcher{}
|
||||
c.ctl = &controller{
|
||||
tagMgr: c.tagMgr,
|
||||
@ -56,7 +56,7 @@ func (c *controllerTestSuite) SetupTest() {
|
||||
|
||||
func (c *controllerTestSuite) TestEnsureTag() {
|
||||
// the tag already exists under the repository and is attached to the artifact
|
||||
c.tagMgr.On("List").Return([]*tag.Tag{
|
||||
c.tagMgr.On("List", mock.Anything, mock.Anything).Return([]*tag.Tag{
|
||||
{
|
||||
ID: 1,
|
||||
RepositoryID: 1,
|
||||
@ -67,7 +67,7 @@ func (c *controllerTestSuite) TestEnsureTag() {
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(&pkg_artifact.Artifact{
|
||||
ID: 1,
|
||||
}, nil)
|
||||
c.immutableMtr.On("Match").Return(false, nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(false, nil)
|
||||
_, err := c.ctl.Ensure(orm.NewContext(nil, &ormtesting.FakeOrmer{}), 1, 1, "latest")
|
||||
c.Require().Nil(err)
|
||||
c.tagMgr.AssertExpectations(c.T())
|
||||
@ -76,7 +76,7 @@ func (c *controllerTestSuite) TestEnsureTag() {
|
||||
c.SetupTest()
|
||||
|
||||
// the tag exists under the repository, but it is attached to other artifact
|
||||
c.tagMgr.On("List").Return([]*tag.Tag{
|
||||
c.tagMgr.On("List", mock.Anything, mock.Anything).Return([]*tag.Tag{
|
||||
{
|
||||
ID: 1,
|
||||
RepositoryID: 1,
|
||||
@ -84,11 +84,11 @@ func (c *controllerTestSuite) TestEnsureTag() {
|
||||
Name: "latest",
|
||||
},
|
||||
}, nil)
|
||||
c.tagMgr.On("Update").Return(nil)
|
||||
c.tagMgr.On("Update", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(&pkg_artifact.Artifact{
|
||||
ID: 1,
|
||||
}, nil)
|
||||
c.immutableMtr.On("Match").Return(false, nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(false, nil)
|
||||
_, err = c.ctl.Ensure(orm.NewContext(nil, &ormtesting.FakeOrmer{}), 1, 1, "latest")
|
||||
c.Require().Nil(err)
|
||||
c.tagMgr.AssertExpectations(c.T())
|
||||
@ -97,26 +97,26 @@ func (c *controllerTestSuite) TestEnsureTag() {
|
||||
c.SetupTest()
|
||||
|
||||
// the tag doesn't exist under the repository, create it
|
||||
c.tagMgr.On("List").Return([]*tag.Tag{}, nil)
|
||||
c.tagMgr.On("Create").Return(1, nil)
|
||||
c.tagMgr.On("List", mock.Anything, mock.Anything).Return([]*tag.Tag{}, nil)
|
||||
c.tagMgr.On("Create", mock.Anything, mock.Anything).Return(int64(1), nil)
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(&pkg_artifact.Artifact{
|
||||
ID: 1,
|
||||
}, nil)
|
||||
c.immutableMtr.On("Match").Return(false, nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(false, nil)
|
||||
_, err = c.ctl.Ensure(orm.NewContext(nil, &ormtesting.FakeOrmer{}), 1, 1, "latest")
|
||||
c.Require().Nil(err)
|
||||
c.tagMgr.AssertExpectations(c.T())
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) TestCount() {
|
||||
c.tagMgr.On("Count").Return(1, nil)
|
||||
c.tagMgr.On("Count", mock.Anything, mock.Anything).Return(int64(1), nil)
|
||||
total, err := c.ctl.Count(nil, nil)
|
||||
c.Require().Nil(err)
|
||||
c.Equal(int64(1), total)
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) TestList() {
|
||||
c.tagMgr.On("List").Return([]*tag.Tag{
|
||||
c.tagMgr.On("List", mock.Anything, mock.Anything).Return([]*tag.Tag{
|
||||
{
|
||||
RepositoryID: 1,
|
||||
Name: "testlist",
|
||||
@ -134,7 +134,7 @@ func (c *controllerTestSuite) TestGet() {
|
||||
getTest.RepositoryID = 1
|
||||
getTest.Name = "testget"
|
||||
|
||||
c.tagMgr.On("Get").Return(getTest, nil)
|
||||
c.tagMgr.On("Get", mock.Anything, mock.Anything).Return(getTest, nil)
|
||||
tag, err := c.ctl.Get(nil, 1, nil)
|
||||
c.Require().Nil(err)
|
||||
c.tagMgr.AssertExpectations(c.T())
|
||||
@ -143,36 +143,36 @@ func (c *controllerTestSuite) TestGet() {
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) TestDelete() {
|
||||
c.tagMgr.On("Get").Return(&tag.Tag{
|
||||
c.tagMgr.On("Get", mock.Anything, mock.Anything).Return(&tag.Tag{
|
||||
RepositoryID: 1,
|
||||
Name: "test",
|
||||
}, nil)
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(&pkg_artifact.Artifact{
|
||||
ID: 1,
|
||||
}, nil)
|
||||
c.immutableMtr.On("Match").Return(false, nil)
|
||||
c.tagMgr.On("Delete").Return(nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(false, nil)
|
||||
c.tagMgr.On("Delete", mock.Anything, mock.Anything).Return(nil)
|
||||
err := c.ctl.Delete(nil, 1)
|
||||
c.Require().Nil(err)
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) TestDeleteImmutable() {
|
||||
c.tagMgr.On("Get").Return(&tag.Tag{
|
||||
c.tagMgr.On("Get", mock.Anything, mock.Anything).Return(&tag.Tag{
|
||||
RepositoryID: 1,
|
||||
Name: "test",
|
||||
}, nil)
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(&pkg_artifact.Artifact{
|
||||
ID: 1,
|
||||
}, nil)
|
||||
c.immutableMtr.On("Match").Return(true, nil)
|
||||
c.tagMgr.On("Delete").Return(nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(true, nil)
|
||||
c.tagMgr.On("Delete", mock.Anything, mock.Anything).Return(nil)
|
||||
err := c.ctl.Delete(nil, 1)
|
||||
c.Require().NotNil(err)
|
||||
c.True(errors.IsErr(err, errors.PreconditionCode))
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) TestUpdate() {
|
||||
c.tagMgr.On("Update").Return(nil)
|
||||
mock.OnAnything(c.tagMgr, "Update").Return(nil)
|
||||
err := c.ctl.Update(nil, &Tag{
|
||||
Tag: tag.Tag{
|
||||
RepositoryID: 1,
|
||||
@ -184,14 +184,14 @@ func (c *controllerTestSuite) TestUpdate() {
|
||||
}
|
||||
|
||||
func (c *controllerTestSuite) TestDeleteTags() {
|
||||
c.tagMgr.On("Get").Return(&tag.Tag{
|
||||
c.tagMgr.On("Get", mock.Anything, mock.Anything).Return(&tag.Tag{
|
||||
RepositoryID: 1,
|
||||
}, nil)
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(&pkg_artifact.Artifact{
|
||||
ID: 1,
|
||||
}, nil)
|
||||
c.immutableMtr.On("Match").Return(false, nil)
|
||||
c.tagMgr.On("Delete").Return(nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(false, nil)
|
||||
c.tagMgr.On("Delete", mock.Anything, mock.Anything).Return(nil)
|
||||
ids := []int64{1, 2, 3, 4}
|
||||
err := c.ctl.DeleteTags(nil, ids)
|
||||
c.Require().Nil(err)
|
||||
@ -218,7 +218,7 @@ func (c *controllerTestSuite) TestAssembleTag() {
|
||||
}
|
||||
|
||||
c.artMgr.On("Get", mock.Anything, mock.Anything).Return(art, nil)
|
||||
c.immutableMtr.On("Match").Return(true, nil)
|
||||
mock.OnAnything(c.immutableMtr, "Match").Return(true, nil)
|
||||
tag := c.ctl.assembleTag(nil, tg, option)
|
||||
c.Require().NotNil(tag)
|
||||
c.Equal(tag.ID, tg.ID)
|
||||
|
@ -42,8 +42,8 @@ import (
|
||||
type gcTestSuite struct {
|
||||
htesting.Suite
|
||||
artifactCtl *artifacttesting.Controller
|
||||
artrashMgr *trashtesting.FakeManager
|
||||
registryCtlClient *registryctl.Mockclient
|
||||
artrashMgr *trashtesting.Manager
|
||||
registryCtlClient *registryctl.Client
|
||||
projectCtl *projecttesting.Controller
|
||||
blobMgr *blob.Manager
|
||||
|
||||
@ -54,8 +54,8 @@ type gcTestSuite struct {
|
||||
|
||||
func (suite *gcTestSuite) SetupTest() {
|
||||
suite.artifactCtl = &artifacttesting.Controller{}
|
||||
suite.artrashMgr = &trashtesting.FakeManager{}
|
||||
suite.registryCtlClient = ®istryctl.Mockclient{}
|
||||
suite.artrashMgr = &trashtesting.Manager{}
|
||||
suite.registryCtlClient = ®istryctl.Client{}
|
||||
suite.blobMgr = &blob.Manager{}
|
||||
suite.projectCtl = &projecttesting.Controller{}
|
||||
|
||||
@ -98,7 +98,7 @@ func (suite *gcTestSuite) TestDeletedArt() {
|
||||
},
|
||||
}, nil)
|
||||
suite.artifactCtl.On("Delete").Return(nil)
|
||||
suite.artrashMgr.On("Filter").Return([]model.ArtifactTrash{
|
||||
mock.OnAnything(suite.artrashMgr, "Filter").Return([]model.ArtifactTrash{
|
||||
{
|
||||
ID: 1,
|
||||
Digest: suite.DigestString(),
|
||||
@ -163,6 +163,8 @@ func (suite *gcTestSuite) TestInit() {
|
||||
"time_window": 1,
|
||||
"workers": float64(3),
|
||||
}
|
||||
|
||||
mock.OnAnything(gc.registryCtlClient, "Health").Return(nil)
|
||||
suite.Nil(gc.init(ctx, params))
|
||||
suite.True(gc.deleteUntagged)
|
||||
suite.Equal(3, gc.workers)
|
||||
@ -230,7 +232,7 @@ func (suite *gcTestSuite) TestRun() {
|
||||
},
|
||||
}, nil)
|
||||
suite.artifactCtl.On("Delete").Return(nil)
|
||||
suite.artrashMgr.On("Filter").Return([]model.ArtifactTrash{}, nil)
|
||||
mock.OnAnything(suite.artrashMgr, "Filter").Return([]model.ArtifactTrash{}, nil)
|
||||
|
||||
mock.OnAnything(suite.projectCtl, "List").Return([]*proModels.Project{
|
||||
{
|
||||
@ -271,6 +273,8 @@ func (suite *gcTestSuite) TestRun() {
|
||||
|
||||
mock.OnAnything(suite.blobMgr, "Delete").Return(nil)
|
||||
|
||||
mock.OnAnything(suite.registryCtlClient, "Health").Return(nil)
|
||||
|
||||
gc := &GarbageCollector{
|
||||
artCtl: suite.artifactCtl,
|
||||
artrashMgr: suite.artrashMgr,
|
||||
@ -284,6 +288,7 @@ func (suite *gcTestSuite) TestRun() {
|
||||
"workers": 3,
|
||||
}
|
||||
|
||||
mock.OnAnything(gc.registryCtlClient, "DeleteBlob").Return(nil)
|
||||
suite.Nil(gc.Run(ctx, params))
|
||||
}
|
||||
|
||||
@ -302,7 +307,7 @@ func (suite *gcTestSuite) TestMark() {
|
||||
},
|
||||
}, nil)
|
||||
suite.artifactCtl.On("Delete").Return(nil)
|
||||
suite.artrashMgr.On("Filter").Return([]model.ArtifactTrash{
|
||||
mock.OnAnything(suite.artrashMgr, "Filter").Return([]model.ArtifactTrash{
|
||||
{
|
||||
ID: 1,
|
||||
Digest: suite.DigestString(),
|
||||
@ -381,6 +386,7 @@ func (suite *gcTestSuite) TestSweep() {
|
||||
workers: 3,
|
||||
}
|
||||
|
||||
mock.OnAnything(gc.registryCtlClient, "DeleteBlob").Return(nil)
|
||||
suite.Nil(gc.sweep(ctx))
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,12 @@ func TestPostScan(t *testing.T) {
|
||||
origRp := &scan.Report{}
|
||||
rawReport := ""
|
||||
|
||||
mocker := &postprocessorstesting.ScanReportV1ToV2Converter{}
|
||||
mocker.On("ToRelationalSchema", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, "original report", nil)
|
||||
mocker := &postprocessorstesting.NativeScanReportConverter{}
|
||||
mocker.On("ToRelationalSchema", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return("", "original report", nil)
|
||||
postprocessors.Converter = mocker
|
||||
sr := &v1.ScanRequest{Artifact: artifact}
|
||||
refreshedReport, err := v.PostScan(ctx, sr, origRp, rawReport, time.Now(), &model.Robot{})
|
||||
assert.Equal(t, "", refreshedReport, "PostScan should return the refreshed report")
|
||||
assert.Equal(t, "original report", refreshedReport, "PostScan should return the refreshed report")
|
||||
assert.Nil(t, err, "PostScan should not return an error")
|
||||
}
|
||||
|
||||
@ -209,6 +209,7 @@ func (suite *VulHandlerTestSuite) TestMakeReportPlaceHolder() {
|
||||
mock.OnAnything(suite.reportMgr, "Create").Return("uuid", nil).Once()
|
||||
mock.OnAnything(suite.reportMgr, "Delete").Return(nil).Once()
|
||||
mock.OnAnything(suite.taskMgr, "ListScanTasksByReportUUID").Return([]*task.Task{{Status: "Success"}}, nil)
|
||||
mock.OnAnything(suite.handler.reportConverter, "FromRelationalSchema").Return("", nil)
|
||||
rps, err := suite.handler.MakePlaceHolder(ctx, art, r)
|
||||
require.NoError(suite.T(), err)
|
||||
assert.Equal(suite.T(), 1, len(rps))
|
||||
|
@ -1,136 +0,0 @@
|
||||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
|
||||
package libcache
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
cache "github.com/goharbor/harbor/src/lib/cache"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Cache is an autogenerated mock type for the Cache type
|
||||
type Cache struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Contains provides a mock function with given fields: ctx, key
|
||||
func (_m *Cache) Contains(ctx context.Context, key string) bool {
|
||||
ret := _m.Called(ctx, key)
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok {
|
||||
r0 = rf(ctx, key)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, key
|
||||
func (_m *Cache) Delete(ctx context.Context, key string) error {
|
||||
ret := _m.Called(ctx, key)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
|
||||
r0 = rf(ctx, key)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Fetch provides a mock function with given fields: ctx, key, value
|
||||
func (_m *Cache) Fetch(ctx context.Context, key string, value interface{}) error {
|
||||
ret := _m.Called(ctx, key, value)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) error); ok {
|
||||
r0 = rf(ctx, key, value)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Ping provides a mock function with given fields: ctx
|
||||
func (_m *Cache) Ping(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: ctx, key, value, expiration
|
||||
func (_m *Cache) Save(ctx context.Context, key string, value interface{}, expiration ...time.Duration) error {
|
||||
_va := make([]interface{}, len(expiration))
|
||||
for _i := range expiration {
|
||||
_va[_i] = expiration[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, key, value)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...time.Duration) error); ok {
|
||||
r0 = rf(ctx, key, value, expiration...)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Scan provides a mock function with given fields: ctx, match
|
||||
func (_m *Cache) Scan(ctx context.Context, match string) (cache.Iterator, error) {
|
||||
ret := _m.Called(ctx, match)
|
||||
|
||||
var r0 cache.Iterator
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (cache.Iterator, error)); ok {
|
||||
return rf(ctx, match)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) cache.Iterator); ok {
|
||||
r0 = rf(ctx, match)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(cache.Iterator)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, match)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewCache interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewCache creates a new instance of Cache. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewCache(t mockConstructorTestingTNewCache) *Cache {
|
||||
mock := &Cache{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
@ -1,38 +1,123 @@
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package artifactrash
|
||||
|
||||
import (
|
||||
"context"
|
||||
context "context"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/goharbor/harbor/src/pkg/artifactrash/model"
|
||||
model "github.com/goharbor/harbor/src/pkg/artifactrash/model"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// FakeManager is a fake tag manager that implement the src/pkg/tag.Manager interface
|
||||
type FakeManager struct {
|
||||
// Manager is an autogenerated mock type for the Manager type
|
||||
type Manager struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Create ...
|
||||
func (f *FakeManager) Create(ctx context.Context, artifactrsh *model.ArtifactTrash) (id int64, err error) {
|
||||
args := f.Called()
|
||||
return int64(args.Int(0)), args.Error(1)
|
||||
// Create provides a mock function with given fields: ctx, artifactrsh
|
||||
func (_m *Manager) Create(ctx context.Context, artifactrsh *model.ArtifactTrash) (int64, error) {
|
||||
ret := _m.Called(ctx, artifactrsh)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Create")
|
||||
}
|
||||
|
||||
var r0 int64
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *model.ArtifactTrash) (int64, error)); ok {
|
||||
return rf(ctx, artifactrsh)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *model.ArtifactTrash) int64); ok {
|
||||
r0 = rf(ctx, artifactrsh)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *model.ArtifactTrash) error); ok {
|
||||
r1 = rf(ctx, artifactrsh)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Delete ...
|
||||
func (f *FakeManager) Delete(ctx context.Context, id int64) error {
|
||||
args := f.Called()
|
||||
return args.Error(0)
|
||||
// Delete provides a mock function with given fields: ctx, id
|
||||
func (_m *Manager) Delete(ctx context.Context, id int64) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Delete")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Filter ...
|
||||
func (f *FakeManager) Filter(ctx context.Context, timeWindow int64) (arts []model.ArtifactTrash, err error) {
|
||||
args := f.Called()
|
||||
return args.Get(0).([]model.ArtifactTrash), args.Error(1)
|
||||
// Filter provides a mock function with given fields: ctx, timeWindow
|
||||
func (_m *Manager) Filter(ctx context.Context, timeWindow int64) ([]model.ArtifactTrash, error) {
|
||||
ret := _m.Called(ctx, timeWindow)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Filter")
|
||||
}
|
||||
|
||||
var r0 []model.ArtifactTrash
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) ([]model.ArtifactTrash, error)); ok {
|
||||
return rf(ctx, timeWindow)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) []model.ArtifactTrash); ok {
|
||||
r0 = rf(ctx, timeWindow)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]model.ArtifactTrash)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
|
||||
r1 = rf(ctx, timeWindow)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Flush ...
|
||||
func (f *FakeManager) Flush(ctx context.Context, timeWindow int64) (err error) {
|
||||
args := f.Called()
|
||||
return args.Error(0)
|
||||
// Flush provides a mock function with given fields: ctx, timeWindow
|
||||
func (_m *Manager) Flush(ctx context.Context, timeWindow int64) error {
|
||||
ret := _m.Called(ctx, timeWindow)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Flush")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, timeWindow)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewManager creates a new instance of Manager. 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 NewManager(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Manager {
|
||||
mock := &Manager{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,33 +1,89 @@
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package chart
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
helm_chart "helm.sh/helm/v3/pkg/chart"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
chart "helm.sh/helm/v3/pkg/chart"
|
||||
|
||||
chartserver "github.com/goharbor/harbor/src/pkg/chart"
|
||||
pkgchart "github.com/goharbor/harbor/src/pkg/chart"
|
||||
)
|
||||
|
||||
// FakeOpertaor ...
|
||||
type FakeOpertaor struct {
|
||||
// Operator is an autogenerated mock type for the Operator type
|
||||
type Operator struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// GetDetails ...
|
||||
func (f *FakeOpertaor) GetDetails(content []byte) (*chartserver.VersionDetails, error) {
|
||||
args := f.Called()
|
||||
var chartDetails *chartserver.VersionDetails
|
||||
if args.Get(0) != nil {
|
||||
chartDetails = args.Get(0).(*chartserver.VersionDetails)
|
||||
// GetData provides a mock function with given fields: content
|
||||
func (_m *Operator) GetData(content []byte) (*chart.Chart, error) {
|
||||
ret := _m.Called(content)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetData")
|
||||
}
|
||||
return chartDetails, args.Error(1)
|
||||
|
||||
var r0 *chart.Chart
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]byte) (*chart.Chart, error)); ok {
|
||||
return rf(content)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]byte) *chart.Chart); ok {
|
||||
r0 = rf(content)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*chart.Chart)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]byte) error); ok {
|
||||
r1 = rf(content)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetData ...
|
||||
func (f *FakeOpertaor) GetData(content []byte) (*helm_chart.Chart, error) {
|
||||
args := f.Called()
|
||||
var chartData *helm_chart.Chart
|
||||
if args.Get(0) != nil {
|
||||
chartData = args.Get(0).(*helm_chart.Chart)
|
||||
// GetDetails provides a mock function with given fields: content
|
||||
func (_m *Operator) GetDetails(content []byte) (*pkgchart.VersionDetails, error) {
|
||||
ret := _m.Called(content)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetDetails")
|
||||
}
|
||||
return chartData, args.Error(1)
|
||||
|
||||
var r0 *pkgchart.VersionDetails
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]byte) (*pkgchart.VersionDetails, error)); ok {
|
||||
return rf(content)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]byte) *pkgchart.VersionDetails); ok {
|
||||
r0 = rf(content)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*pkgchart.VersionDetails)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]byte) error); ok {
|
||||
r1 = rf(content)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewOperator creates a new instance of Operator. 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 NewOperator(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Operator {
|
||||
mock := &Operator{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated by mockery v2.22.1. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package distribution
|
||||
|
||||
@ -16,6 +16,10 @@ type Manifest struct {
|
||||
func (_m *Manifest) Payload() (string, []byte, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Payload")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 []byte
|
||||
var r2 error
|
||||
@ -49,6 +53,10 @@ func (_m *Manifest) Payload() (string, []byte, error) {
|
||||
func (_m *Manifest) References() []distribution.Descriptor {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for References")
|
||||
}
|
||||
|
||||
var r0 []distribution.Descriptor
|
||||
if rf, ok := ret.Get(0).(func() []distribution.Descriptor); ok {
|
||||
r0 = rf()
|
||||
@ -61,13 +69,12 @@ func (_m *Manifest) References() []distribution.Descriptor {
|
||||
return r0
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewManifest interface {
|
||||
// NewManifest creates a new instance of Manifest. 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 NewManifest(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewManifest creates a new instance of Manifest. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewManifest(t mockConstructorTestingTNewManifest) *Manifest {
|
||||
}) *Manifest {
|
||||
mock := &Manifest{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
@ -1,20 +1,58 @@
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package immutable
|
||||
|
||||
import (
|
||||
"context"
|
||||
context "context"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/selector"
|
||||
selector "github.com/goharbor/harbor/src/lib/selector"
|
||||
)
|
||||
|
||||
// FakeMatcher ...
|
||||
// FakeMatcher is an autogenerated mock type for the ImmutableTagMatcher type
|
||||
type FakeMatcher struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Match ...
|
||||
func (f *FakeMatcher) Match(ctx context.Context, pid int64, c selector.Candidate) (bool, error) {
|
||||
args := f.Called()
|
||||
return args.Bool(0), args.Error(1)
|
||||
// Match provides a mock function with given fields: ctx, pid, c
|
||||
func (_m *FakeMatcher) Match(ctx context.Context, pid int64, c selector.Candidate) (bool, error) {
|
||||
ret := _m.Called(ctx, pid, c)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Match")
|
||||
}
|
||||
|
||||
var r0 bool
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, selector.Candidate) (bool, error)); ok {
|
||||
return rf(ctx, pid, c)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, selector.Candidate) bool); ok {
|
||||
r0 = rf(ctx, pid, c)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64, selector.Candidate) error); ok {
|
||||
r1 = rf(ctx, pid, c)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewFakeMatcher creates a new instance of FakeMatcher. 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 NewFakeMatcher(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *FakeMatcher {
|
||||
mock := &FakeMatcher{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated by mockery v1.0.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package instance
|
||||
|
||||
@ -7,27 +7,35 @@ import (
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
q "github.com/goharbor/harbor/src/lib/q"
|
||||
provider "github.com/goharbor/harbor/src/pkg/p2p/preheat/models/provider"
|
||||
|
||||
q "github.com/goharbor/harbor/src/lib/q"
|
||||
)
|
||||
|
||||
// FakeManager is an autogenerated mock type for the Manager type
|
||||
type FakeManager struct {
|
||||
// Manager is an autogenerated mock type for the Manager type
|
||||
type Manager struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Count provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeManager) Count(ctx context.Context, query *q.Query) (int64, error) {
|
||||
func (_m *Manager) Count(ctx context.Context, query *q.Query) (int64, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
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, *q.Query) (int64, error)); ok {
|
||||
return rf(ctx, query)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) int64); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
@ -38,9 +46,13 @@ func (_m *FakeManager) Count(ctx context.Context, query *q.Query) (int64, error)
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, id
|
||||
func (_m *FakeManager) Delete(ctx context.Context, id int64) error {
|
||||
func (_m *Manager) Delete(ctx context.Context, id int64) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Delete")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, id)
|
||||
@ -52,10 +64,18 @@ func (_m *FakeManager) Delete(ctx context.Context, id int64) error {
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, id
|
||||
func (_m *FakeManager) Get(ctx context.Context, id int64) (*provider.Instance, error) {
|
||||
func (_m *Manager) Get(ctx context.Context, id int64) (*provider.Instance, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 *provider.Instance
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) (*provider.Instance, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) *provider.Instance); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
@ -64,7 +84,6 @@ func (_m *FakeManager) Get(ctx context.Context, id int64) (*provider.Instance, e
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
@ -75,10 +94,18 @@ func (_m *FakeManager) Get(ctx context.Context, id int64) (*provider.Instance, e
|
||||
}
|
||||
|
||||
// GetByName provides a mock function with given fields: ctx, name
|
||||
func (_m *FakeManager) GetByName(ctx context.Context, name string) (*provider.Instance, error) {
|
||||
func (_m *Manager) GetByName(ctx context.Context, name string) (*provider.Instance, error) {
|
||||
ret := _m.Called(ctx, name)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetByName")
|
||||
}
|
||||
|
||||
var r0 *provider.Instance
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (*provider.Instance, error)); ok {
|
||||
return rf(ctx, name)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) *provider.Instance); ok {
|
||||
r0 = rf(ctx, name)
|
||||
} else {
|
||||
@ -87,7 +114,6 @@ func (_m *FakeManager) GetByName(ctx context.Context, name string) (*provider.In
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, name)
|
||||
} else {
|
||||
@ -98,10 +124,18 @@ func (_m *FakeManager) GetByName(ctx context.Context, name string) (*provider.In
|
||||
}
|
||||
|
||||
// List provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeManager) List(ctx context.Context, query *q.Query) ([]*provider.Instance, error) {
|
||||
func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*provider.Instance, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for List")
|
||||
}
|
||||
|
||||
var r0 []*provider.Instance
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*provider.Instance, error)); ok {
|
||||
return rf(ctx, query)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*provider.Instance); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
@ -110,7 +144,6 @@ func (_m *FakeManager) List(ctx context.Context, query *q.Query) ([]*provider.In
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
@ -121,17 +154,24 @@ func (_m *FakeManager) List(ctx context.Context, query *q.Query) ([]*provider.In
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: ctx, inst
|
||||
func (_m *FakeManager) Save(ctx context.Context, inst *provider.Instance) (int64, error) {
|
||||
func (_m *Manager) Save(ctx context.Context, inst *provider.Instance) (int64, error) {
|
||||
ret := _m.Called(ctx, inst)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Save")
|
||||
}
|
||||
|
||||
var r0 int64
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *provider.Instance) (int64, error)); ok {
|
||||
return rf(ctx, inst)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *provider.Instance) int64); ok {
|
||||
r0 = rf(ctx, inst)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *provider.Instance) error); ok {
|
||||
r1 = rf(ctx, inst)
|
||||
} else {
|
||||
@ -142,7 +182,7 @@ func (_m *FakeManager) Save(ctx context.Context, inst *provider.Instance) (int64
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: ctx, inst, props
|
||||
func (_m *FakeManager) Update(ctx context.Context, inst *provider.Instance, props ...string) error {
|
||||
func (_m *Manager) Update(ctx context.Context, inst *provider.Instance, props ...string) error {
|
||||
_va := make([]interface{}, len(props))
|
||||
for _i := range props {
|
||||
_va[_i] = props[_i]
|
||||
@ -152,6 +192,10 @@ func (_m *FakeManager) Update(ctx context.Context, inst *provider.Instance, prop
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Update")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *provider.Instance, ...string) error); ok {
|
||||
r0 = rf(ctx, inst, props...)
|
||||
@ -161,3 +205,17 @@ func (_m *FakeManager) Update(ctx context.Context, inst *provider.Instance, prop
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewManager creates a new instance of Manager. 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 NewManager(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Manager {
|
||||
mock := &Manager{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,33 +1,40 @@
|
||||
// Code generated by mockery v2.0.3. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package policy
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
modelspolicy "github.com/goharbor/harbor/src/pkg/p2p/preheat/models/policy"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
q "github.com/goharbor/harbor/src/lib/q"
|
||||
modelspolicy "github.com/goharbor/harbor/src/pkg/p2p/preheat/models/policy"
|
||||
)
|
||||
|
||||
// FakeManager is an autogenerated mock type for the Manager type
|
||||
type FakeManager struct {
|
||||
// Manager is an autogenerated mock type for the Manager type
|
||||
type Manager struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Count provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeManager) Count(ctx context.Context, query *q.Query) (int64, error) {
|
||||
func (_m *Manager) Count(ctx context.Context, query *q.Query) (int64, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
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, *q.Query) (int64, error)); ok {
|
||||
return rf(ctx, query)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) int64); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
@ -38,17 +45,24 @@ func (_m *FakeManager) Count(ctx context.Context, query *q.Query) (int64, error)
|
||||
}
|
||||
|
||||
// Create provides a mock function with given fields: ctx, schema
|
||||
func (_m *FakeManager) Create(ctx context.Context, schema *modelspolicy.Schema) (int64, error) {
|
||||
func (_m *Manager) Create(ctx context.Context, schema *modelspolicy.Schema) (int64, error) {
|
||||
ret := _m.Called(ctx, schema)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Create")
|
||||
}
|
||||
|
||||
var r0 int64
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *modelspolicy.Schema) (int64, error)); ok {
|
||||
return rf(ctx, schema)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *modelspolicy.Schema) int64); ok {
|
||||
r0 = rf(ctx, schema)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *modelspolicy.Schema) error); ok {
|
||||
r1 = rf(ctx, schema)
|
||||
} else {
|
||||
@ -59,9 +73,13 @@ func (_m *FakeManager) Create(ctx context.Context, schema *modelspolicy.Schema)
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, id
|
||||
func (_m *FakeManager) Delete(ctx context.Context, id int64) error {
|
||||
func (_m *Manager) Delete(ctx context.Context, id int64) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Delete")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, id)
|
||||
@ -73,10 +91,18 @@ func (_m *FakeManager) Delete(ctx context.Context, id int64) error {
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, id
|
||||
func (_m *FakeManager) Get(ctx context.Context, id int64) (*modelspolicy.Schema, error) {
|
||||
func (_m *Manager) Get(ctx context.Context, id int64) (*modelspolicy.Schema, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 *modelspolicy.Schema
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) (*modelspolicy.Schema, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) *modelspolicy.Schema); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
@ -85,7 +111,6 @@ func (_m *FakeManager) Get(ctx context.Context, id int64) (*modelspolicy.Schema,
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
@ -95,22 +120,29 @@ func (_m *FakeManager) Get(ctx context.Context, id int64) (*modelspolicy.Schema,
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetByName provides a mock function with given fields: ctx, projectId, name
|
||||
func (_m *FakeManager) GetByName(ctx context.Context, projectId int64, name string) (*modelspolicy.Schema, error) {
|
||||
ret := _m.Called(ctx, projectId, name)
|
||||
// GetByName provides a mock function with given fields: ctx, projectID, name
|
||||
func (_m *Manager) GetByName(ctx context.Context, projectID int64, name string) (*modelspolicy.Schema, error) {
|
||||
ret := _m.Called(ctx, projectID, name)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetByName")
|
||||
}
|
||||
|
||||
var r0 *modelspolicy.Schema
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*modelspolicy.Schema, error)); ok {
|
||||
return rf(ctx, projectID, name)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, string) *modelspolicy.Schema); ok {
|
||||
r0 = rf(ctx, projectId, name)
|
||||
r0 = rf(ctx, projectID, name)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*modelspolicy.Schema)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok {
|
||||
r1 = rf(ctx, projectId, name)
|
||||
r1 = rf(ctx, projectID, name)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@ -119,10 +151,18 @@ func (_m *FakeManager) GetByName(ctx context.Context, projectId int64, name stri
|
||||
}
|
||||
|
||||
// ListPolicies provides a mock function with given fields: ctx, query
|
||||
func (_m *FakeManager) ListPolicies(ctx context.Context, query *q.Query) ([]*modelspolicy.Schema, error) {
|
||||
func (_m *Manager) ListPolicies(ctx context.Context, query *q.Query) ([]*modelspolicy.Schema, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListPolicies")
|
||||
}
|
||||
|
||||
var r0 []*modelspolicy.Schema
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*modelspolicy.Schema, error)); ok {
|
||||
return rf(ctx, query)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*modelspolicy.Schema); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
@ -131,7 +171,6 @@ func (_m *FakeManager) ListPolicies(ctx context.Context, query *q.Query) ([]*mod
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
@ -142,10 +181,18 @@ func (_m *FakeManager) ListPolicies(ctx context.Context, query *q.Query) ([]*mod
|
||||
}
|
||||
|
||||
// ListPoliciesByProject provides a mock function with given fields: ctx, project, query
|
||||
func (_m *FakeManager) ListPoliciesByProject(ctx context.Context, project int64, query *q.Query) ([]*modelspolicy.Schema, error) {
|
||||
func (_m *Manager) ListPoliciesByProject(ctx context.Context, project int64, query *q.Query) ([]*modelspolicy.Schema, error) {
|
||||
ret := _m.Called(ctx, project, query)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListPoliciesByProject")
|
||||
}
|
||||
|
||||
var r0 []*modelspolicy.Schema
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, *q.Query) ([]*modelspolicy.Schema, error)); ok {
|
||||
return rf(ctx, project, query)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64, *q.Query) []*modelspolicy.Schema); ok {
|
||||
r0 = rf(ctx, project, query)
|
||||
} else {
|
||||
@ -154,7 +201,6 @@ func (_m *FakeManager) ListPoliciesByProject(ctx context.Context, project int64,
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64, *q.Query) error); ok {
|
||||
r1 = rf(ctx, project, query)
|
||||
} else {
|
||||
@ -165,7 +211,7 @@ func (_m *FakeManager) ListPoliciesByProject(ctx context.Context, project int64,
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: ctx, schema, props
|
||||
func (_m *FakeManager) Update(ctx context.Context, schema *modelspolicy.Schema, props ...string) error {
|
||||
func (_m *Manager) Update(ctx context.Context, schema *modelspolicy.Schema, props ...string) error {
|
||||
_va := make([]interface{}, len(props))
|
||||
for _i := range props {
|
||||
_va[_i] = props[_i]
|
||||
@ -175,6 +221,10 @@ func (_m *FakeManager) Update(ctx context.Context, schema *modelspolicy.Schema,
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Update")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *modelspolicy.Schema, ...string) error); ok {
|
||||
r0 = rf(ctx, schema, props...)
|
||||
@ -184,3 +234,17 @@ func (_m *FakeManager) Update(ctx context.Context, schema *modelspolicy.Schema,
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewManager creates a new instance of Manager. 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 NewManager(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Manager {
|
||||
mock := &Manager{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
// Code generated by mockery v2.1.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package parser
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
artifact "github.com/goharbor/harbor/src/pkg/artifact"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// Parser is an autogenerated mock type for the Parser type
|
||||
@ -19,6 +19,10 @@ type Parser struct {
|
||||
func (_m *Parser) Parse(ctx context.Context, _a1 *artifact.Artifact, manifest []byte) error {
|
||||
ret := _m.Called(ctx, _a1, manifest)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Parse")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *artifact.Artifact, []byte) error); ok {
|
||||
r0 = rf(ctx, _a1, manifest)
|
||||
@ -28,3 +32,17 @@ func (_m *Parser) Parse(ctx context.Context, _a1 *artifact.Artifact, manifest []
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewParser creates a new instance of Parser. 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 NewParser(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Parser {
|
||||
mock := &Parser{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
// Code generated by mockery v2.1.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package processor
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
artifact "github.com/goharbor/harbor/src/pkg/artifact"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
processor "github.com/goharbor/harbor/src/controller/artifact/processor"
|
||||
artifact "github.com/goharbor/harbor/src/pkg/artifact"
|
||||
)
|
||||
|
||||
// Processor is an autogenerated mock type for the Processor type
|
||||
@ -20,7 +21,15 @@ type Processor struct {
|
||||
func (_m *Processor) AbstractAddition(ctx context.Context, _a1 *artifact.Artifact, additionType string) (*processor.Addition, error) {
|
||||
ret := _m.Called(ctx, _a1, additionType)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AbstractAddition")
|
||||
}
|
||||
|
||||
var r0 *processor.Addition
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *artifact.Artifact, string) (*processor.Addition, error)); ok {
|
||||
return rf(ctx, _a1, additionType)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *artifact.Artifact, string) *processor.Addition); ok {
|
||||
r0 = rf(ctx, _a1, additionType)
|
||||
} else {
|
||||
@ -29,7 +38,6 @@ func (_m *Processor) AbstractAddition(ctx context.Context, _a1 *artifact.Artifac
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *artifact.Artifact, string) error); ok {
|
||||
r1 = rf(ctx, _a1, additionType)
|
||||
} else {
|
||||
@ -43,6 +51,10 @@ func (_m *Processor) AbstractAddition(ctx context.Context, _a1 *artifact.Artifac
|
||||
func (_m *Processor) AbstractMetadata(ctx context.Context, _a1 *artifact.Artifact, manifest []byte) error {
|
||||
ret := _m.Called(ctx, _a1, manifest)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AbstractMetadata")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *artifact.Artifact, []byte) error); ok {
|
||||
r0 = rf(ctx, _a1, manifest)
|
||||
@ -57,6 +69,10 @@ func (_m *Processor) AbstractMetadata(ctx context.Context, _a1 *artifact.Artifac
|
||||
func (_m *Processor) GetArtifactType(ctx context.Context, _a1 *artifact.Artifact) string {
|
||||
ret := _m.Called(ctx, _a1)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetArtifactType")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *artifact.Artifact) string); ok {
|
||||
r0 = rf(ctx, _a1)
|
||||
@ -71,6 +87,10 @@ func (_m *Processor) GetArtifactType(ctx context.Context, _a1 *artifact.Artifact
|
||||
func (_m *Processor) ListAdditionTypes(ctx context.Context, _a1 *artifact.Artifact) []string {
|
||||
ret := _m.Called(ctx, _a1)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListAdditionTypes")
|
||||
}
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *artifact.Artifact) []string); ok {
|
||||
r0 = rf(ctx, _a1)
|
||||
@ -82,3 +102,17 @@ func (_m *Processor) ListAdditionTypes(ctx context.Context, _a1 *artifact.Artifa
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewProcessor creates a new instance of Processor. 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 NewProcessor(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Processor {
|
||||
mock := &Processor{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,256 +0,0 @@
|
||||
// Code generated by mockery v2.1.0. DO NOT EDIT.
|
||||
|
||||
package scan
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
q "github.com/goharbor/harbor/src/lib/q"
|
||||
scan "github.com/goharbor/harbor/src/pkg/scan/dao/scan"
|
||||
)
|
||||
|
||||
// VulnerabilityRecordDao is an autogenerated mock type for the VulnerabilityRecordDao type
|
||||
type VulnerabilityRecordDao struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Create provides a mock function with given fields: ctx, vr
|
||||
func (_m *VulnerabilityRecordDao) Create(ctx context.Context, vr *scan.VulnerabilityRecord) (int64, error) {
|
||||
ret := _m.Called(ctx, vr)
|
||||
|
||||
var r0 int64
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *scan.VulnerabilityRecord) int64); ok {
|
||||
r0 = rf(ctx, vr)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *scan.VulnerabilityRecord) error); ok {
|
||||
r1 = rf(ctx, vr)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, vr
|
||||
func (_m *VulnerabilityRecordDao) Delete(ctx context.Context, vr *scan.VulnerabilityRecord) error {
|
||||
ret := _m.Called(ctx, vr)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *scan.VulnerabilityRecord) error); ok {
|
||||
r0 = rf(ctx, vr)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteForDigests provides a mock function with given fields: ctx, digests
|
||||
func (_m *VulnerabilityRecordDao) DeleteForDigests(ctx context.Context, digests ...string) (int64, error) {
|
||||
_va := make([]interface{}, len(digests))
|
||||
for _i := range digests {
|
||||
_va[_i] = digests[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 int64
|
||||
if rf, ok := ret.Get(0).(func(context.Context, ...string) int64); ok {
|
||||
r0 = rf(ctx, digests...)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, ...string) error); ok {
|
||||
r1 = rf(ctx, digests...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DeleteForReport provides a mock function with given fields: ctx, reportUUID
|
||||
func (_m *VulnerabilityRecordDao) DeleteForReport(ctx context.Context, reportUUID string) (int64, error) {
|
||||
ret := _m.Called(ctx, reportUUID)
|
||||
|
||||
var r0 int64
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) int64); ok {
|
||||
r0 = rf(ctx, reportUUID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, reportUUID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// DeleteForScanner provides a mock function with given fields: ctx, registrationUUID
|
||||
func (_m *VulnerabilityRecordDao) DeleteForScanner(ctx context.Context, registrationUUID string) (int64, error) {
|
||||
ret := _m.Called(ctx, registrationUUID)
|
||||
|
||||
var r0 int64
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) int64); ok {
|
||||
r0 = rf(ctx, registrationUUID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, registrationUUID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetForReport provides a mock function with given fields: ctx, reportUUID
|
||||
func (_m *VulnerabilityRecordDao) GetForReport(ctx context.Context, reportUUID string) ([]*scan.VulnerabilityRecord, error) {
|
||||
ret := _m.Called(ctx, reportUUID)
|
||||
|
||||
var r0 []*scan.VulnerabilityRecord
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) []*scan.VulnerabilityRecord); ok {
|
||||
r0 = rf(ctx, reportUUID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*scan.VulnerabilityRecord)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, reportUUID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetForScanner provides a mock function with given fields: ctx, registrationUUID
|
||||
func (_m *VulnerabilityRecordDao) GetForScanner(ctx context.Context, registrationUUID string) ([]*scan.VulnerabilityRecord, error) {
|
||||
ret := _m.Called(ctx, registrationUUID)
|
||||
|
||||
var r0 []*scan.VulnerabilityRecord
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) []*scan.VulnerabilityRecord); ok {
|
||||
r0 = rf(ctx, registrationUUID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*scan.VulnerabilityRecord)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, registrationUUID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetRecordIdsForScanner provides a mock function with given fields: ctx, registrationUUID
|
||||
func (_m *VulnerabilityRecordDao) GetRecordIdsForScanner(ctx context.Context, registrationUUID string) ([]int, error) {
|
||||
ret := _m.Called(ctx, registrationUUID)
|
||||
|
||||
var r0 []int
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) []int); ok {
|
||||
r0 = rf(ctx, registrationUUID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]int)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, registrationUUID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// InsertForReport provides a mock function with given fields: ctx, reportUUID, vulnerabilityRecordIDs
|
||||
func (_m *VulnerabilityRecordDao) InsertForReport(ctx context.Context, reportUUID string, vulnerabilityRecordIDs ...int64) error {
|
||||
_va := make([]interface{}, len(vulnerabilityRecordIDs))
|
||||
for _i := range vulnerabilityRecordIDs {
|
||||
_va[_i] = vulnerabilityRecordIDs[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, reportUUID)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, ...int64) error); ok {
|
||||
r0 = rf(ctx, reportUUID, vulnerabilityRecordIDs...)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// List provides a mock function with given fields: ctx, query
|
||||
func (_m *VulnerabilityRecordDao) List(ctx context.Context, query *q.Query) ([]*scan.VulnerabilityRecord, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
var r0 []*scan.VulnerabilityRecord
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*scan.VulnerabilityRecord); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*scan.VulnerabilityRecord)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: ctx, vr, cols
|
||||
func (_m *VulnerabilityRecordDao) Update(ctx context.Context, vr *scan.VulnerabilityRecord, cols ...string) error {
|
||||
_va := make([]interface{}, len(cols))
|
||||
for _i := range cols {
|
||||
_va[_i] = cols[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, vr)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *scan.VulnerabilityRecord, ...string) error); ok {
|
||||
r0 = rf(ctx, vr, cols...)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package postprocessors
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NativeScanReportConverter is an autogenerated mock type for the NativeScanReportConverter type
|
||||
type NativeScanReportConverter struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// FromRelationalSchema provides a mock function with given fields: ctx, reportUUID, artifactDigest, reportSummary
|
||||
func (_m *NativeScanReportConverter) FromRelationalSchema(ctx context.Context, reportUUID string, artifactDigest string, reportSummary string) (string, error) {
|
||||
ret := _m.Called(ctx, reportUUID, artifactDigest, reportSummary)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FromRelationalSchema")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (string, error)); ok {
|
||||
return rf(ctx, reportUUID, artifactDigest, reportSummary)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, string) string); ok {
|
||||
r0 = rf(ctx, reportUUID, artifactDigest, reportSummary)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok {
|
||||
r1 = rf(ctx, reportUUID, artifactDigest, reportSummary)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ToRelationalSchema provides a mock function with given fields: ctx, reportUUID, registrationUUID, digest, reportData
|
||||
func (_m *NativeScanReportConverter) ToRelationalSchema(ctx context.Context, reportUUID string, registrationUUID string, digest string, reportData string) (string, string, error) {
|
||||
ret := _m.Called(ctx, reportUUID, registrationUUID, digest, reportData)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ToRelationalSchema")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 string
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) (string, string, error)); ok {
|
||||
return rf(ctx, reportUUID, registrationUUID, digest, reportData)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) string); ok {
|
||||
r0 = rf(ctx, reportUUID, registrationUUID, digest, reportData)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string, string, string) string); ok {
|
||||
r1 = rf(ctx, reportUUID, registrationUUID, digest, reportData)
|
||||
} else {
|
||||
r1 = ret.Get(1).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(2).(func(context.Context, string, string, string, string) error); ok {
|
||||
r2 = rf(ctx, reportUUID, registrationUUID, digest, reportData)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// NewNativeScanReportConverter creates a new instance of NativeScanReportConverter. 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 NewNativeScanReportConverter(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *NativeScanReportConverter {
|
||||
mock := &NativeScanReportConverter{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package postprocessors
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// ScanReportV1ToV2Converter is an auto-generated mock type for converting native Harbor report in JSON
|
||||
// to relational schema
|
||||
type ScanReportV1ToV2Converter struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// ToRelationalSchema is a mock implementation of the scan report conversion
|
||||
func (_c *ScanReportV1ToV2Converter) ToRelationalSchema(ctx context.Context, reportUUID string, registrationUUID string, digest string, reportData string) (string, string, error) {
|
||||
return "mockId", reportData, nil
|
||||
}
|
||||
|
||||
// ToRelationalSchema is a mock implementation of the scan report conversion
|
||||
func (_c *ScanReportV1ToV2Converter) FromRelationalSchema(ctx context.Context, reportUUID string, artifactDigest string, reportData string) (string, error) {
|
||||
return "mockId", nil
|
||||
}
|
@ -1,79 +1,208 @@
|
||||
// Copyright Project Harbor Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package tag
|
||||
|
||||
import (
|
||||
"context"
|
||||
context "context"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
modeltag "github.com/goharbor/harbor/src/pkg/tag/model/tag"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
"github.com/goharbor/harbor/src/pkg/tag/model/tag"
|
||||
q "github.com/goharbor/harbor/src/lib/q"
|
||||
)
|
||||
|
||||
// FakeManager is a fake tag manager that implement the src/pkg/tag.Manager interface
|
||||
type FakeManager struct {
|
||||
// Manager is an autogenerated mock type for the Manager type
|
||||
type Manager struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Count ...
|
||||
func (f *FakeManager) Count(ctx context.Context, query *q.Query) (int64, error) {
|
||||
args := f.Called()
|
||||
return int64(args.Int(0)), args.Error(1)
|
||||
}
|
||||
// Count provides a mock function with given fields: ctx, query
|
||||
func (_m *Manager) Count(ctx context.Context, query *q.Query) (int64, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
// List ...
|
||||
func (f *FakeManager) List(ctx context.Context, query *q.Query) ([]*tag.Tag, error) {
|
||||
args := f.Called()
|
||||
var tags []*tag.Tag
|
||||
if args.Get(0) != nil {
|
||||
tags = args.Get(0).([]*tag.Tag)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Count")
|
||||
}
|
||||
return tags, args.Error(1)
|
||||
}
|
||||
|
||||
// Get ...
|
||||
func (f *FakeManager) Get(ctx context.Context, id int64) (*tag.Tag, error) {
|
||||
args := f.Called()
|
||||
var tg *tag.Tag
|
||||
if args.Get(0) != nil {
|
||||
tg = args.Get(0).(*tag.Tag)
|
||||
var r0 int64
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) (int64, error)); ok {
|
||||
return rf(ctx, query)
|
||||
}
|
||||
return tg, args.Error(1)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) int64); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Create ...
|
||||
func (f *FakeManager) Create(ctx context.Context, tag *tag.Tag) (int64, error) {
|
||||
args := f.Called()
|
||||
return int64(args.Int(0)), args.Error(1)
|
||||
// Create provides a mock function with given fields: ctx, _a1
|
||||
func (_m *Manager) Create(ctx context.Context, _a1 *modeltag.Tag) (int64, error) {
|
||||
ret := _m.Called(ctx, _a1)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Create")
|
||||
}
|
||||
|
||||
var r0 int64
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *modeltag.Tag) (int64, error)); ok {
|
||||
return rf(ctx, _a1)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *modeltag.Tag) int64); ok {
|
||||
r0 = rf(ctx, _a1)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *modeltag.Tag) error); ok {
|
||||
r1 = rf(ctx, _a1)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Update ...
|
||||
func (f *FakeManager) Update(ctx context.Context, tag *tag.Tag, props ...string) error {
|
||||
args := f.Called()
|
||||
return args.Error(0)
|
||||
// Delete provides a mock function with given fields: ctx, id
|
||||
func (_m *Manager) Delete(ctx context.Context, id int64) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Delete")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Delete ...
|
||||
func (f *FakeManager) Delete(ctx context.Context, id int64) error {
|
||||
args := f.Called()
|
||||
return args.Error(0)
|
||||
// DeleteOfArtifact provides a mock function with given fields: ctx, artifactID
|
||||
func (_m *Manager) DeleteOfArtifact(ctx context.Context, artifactID int64) error {
|
||||
ret := _m.Called(ctx, artifactID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeleteOfArtifact")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
|
||||
r0 = rf(ctx, artifactID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteOfArtifact ...
|
||||
func (f *FakeManager) DeleteOfArtifact(ctx context.Context, artifactID int64) error {
|
||||
args := f.Called()
|
||||
return args.Error(0)
|
||||
// Get provides a mock function with given fields: ctx, id
|
||||
func (_m *Manager) Get(ctx context.Context, id int64) (*modeltag.Tag, error) {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 *modeltag.Tag
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) (*modeltag.Tag, error)); ok {
|
||||
return rf(ctx, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int64) *modeltag.Tag); ok {
|
||||
r0 = rf(ctx, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*modeltag.Tag)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
|
||||
r1 = rf(ctx, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// List provides a mock function with given fields: ctx, query
|
||||
func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*modeltag.Tag, error) {
|
||||
ret := _m.Called(ctx, query)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for List")
|
||||
}
|
||||
|
||||
var r0 []*modeltag.Tag
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*modeltag.Tag, error)); ok {
|
||||
return rf(ctx, query)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*modeltag.Tag); ok {
|
||||
r0 = rf(ctx, query)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*modeltag.Tag)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *q.Query) error); ok {
|
||||
r1 = rf(ctx, query)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: ctx, _a1, props
|
||||
func (_m *Manager) Update(ctx context.Context, _a1 *modeltag.Tag, props ...string) error {
|
||||
_va := make([]interface{}, len(props))
|
||||
for _i := range props {
|
||||
_va[_i] = props[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, _a1)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Update")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *modeltag.Tag, ...string) error); ok {
|
||||
r0 = rf(ctx, _a1, props...)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewManager creates a new instance of Manager. 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 NewManager(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Manager {
|
||||
mock := &Manager{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
@ -1,24 +1,78 @@
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
package registryctl
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
type Mockclient struct {
|
||||
// Client is an autogenerated mock type for the Client type
|
||||
type Client struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Health ...
|
||||
func (c *Mockclient) Health() error {
|
||||
return nil
|
||||
// DeleteBlob provides a mock function with given fields: reference
|
||||
func (_m *Client) DeleteBlob(reference string) error {
|
||||
ret := _m.Called(reference)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeleteBlob")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string) error); ok {
|
||||
r0 = rf(reference)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteBlob ...
|
||||
func (c *Mockclient) DeleteBlob(reference string) (err error) {
|
||||
return nil
|
||||
// DeleteManifest provides a mock function with given fields: repository, reference
|
||||
func (_m *Client) DeleteManifest(repository string, reference string) error {
|
||||
ret := _m.Called(repository, reference)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeleteManifest")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(repository, reference)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteManifest ...
|
||||
func (c *Mockclient) DeleteManifest(repository, reference string) (err error) {
|
||||
return nil
|
||||
// Health provides a mock function with given fields:
|
||||
func (_m *Client) Health() error {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Health")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func() error); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewClient creates a new instance of Client. 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 NewClient(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Client {
|
||||
mock := &Client{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user