fix: import optimization (#18727)

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guangwu 2023-05-30 13:24:08 +08:00 committed by GitHub
parent 14192dfb06
commit b7b0e43a21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 31 deletions

View File

@ -40,7 +40,6 @@ import (
model_tag "github.com/goharbor/harbor/src/pkg/tag/model/tag"
tagtesting "github.com/goharbor/harbor/src/testing/controller/tag"
ormtesting "github.com/goharbor/harbor/src/testing/lib/orm"
"github.com/goharbor/harbor/src/testing/pkg/accessory"
accessorytesting "github.com/goharbor/harbor/src/testing/pkg/accessory"
arttesting "github.com/goharbor/harbor/src/testing/pkg/artifact"
artrashtesting "github.com/goharbor/harbor/src/testing/pkg/artifactrash"
@ -74,7 +73,7 @@ type controllerTestSuite struct {
abstractor *fakeAbstractor
immutableMtr *immutable.FakeMatcher
regCli *registry.Client
accMgr *accessory.Manager
accMgr *accessorytesting.Manager
}
func (c *controllerTestSuite) SetupTest() {

View File

@ -24,7 +24,6 @@ import (
"github.com/goharbor/harbor/src/lib/q"
accessorymodel "github.com/goharbor/harbor/src/pkg/accessory/model"
"github.com/goharbor/harbor/src/pkg/artifact"
"github.com/goharbor/harbor/src/testing/pkg/accessory"
accessorytesting "github.com/goharbor/harbor/src/testing/pkg/accessory"
artifacttesting "github.com/goharbor/harbor/src/testing/pkg/artifact"
)
@ -33,7 +32,7 @@ type IteratorTestSuite struct {
suite.Suite
artMgr *artifacttesting.Manager
accMgr *accessory.Manager
accMgr *accessorytesting.Manager
ctl *controller
originalCtl Controller

View File

@ -25,7 +25,6 @@ import (
"github.com/stretchr/testify/suite"
"github.com/goharbor/harbor/src/lib/errors"
"github.com/goharbor/harbor/src/pkg/blob"
pkg_blob "github.com/goharbor/harbor/src/pkg/blob"
"github.com/goharbor/harbor/src/pkg/blob/models"
"github.com/goharbor/harbor/src/pkg/distribution"
@ -160,7 +159,7 @@ func (suite *ControllerTestSuite) TestFindMissingAssociationsForProjectByArtifac
suite.Len(blobs, 0)
}
blobs := []*blob.Blob{{Digest: "1"}, {Digest: "2"}, {Digest: "3"}}
blobs := []*pkg_blob.Blob{{Digest: "1"}, {Digest: "2"}, {Digest: "3"}}
{
mock.OnAnything(blobMgr, "List").Return(nil, nil).Once()
@ -177,7 +176,7 @@ func (suite *ControllerTestSuite) TestFindMissingAssociationsForProjectByArtifac
}
{
associated := []*blob.Blob{{Digest: "1"}}
associated := []*pkg_blob.Blob{{Digest: "1"}}
mock.OnAnything(blobMgr, "List").Return(associated, nil).Once()
missing, err := ctl.FindMissingAssociationsForProject(ctx, projectID, blobs)
suite.Nil(err)
@ -312,7 +311,7 @@ func (suite *ControllerTestSuite) TestGetSetAcceptedBlobSize() {
func (suite *ControllerTestSuite) TestTouch() {
ctx := suite.Context()
err := Ctl.Touch(ctx, &blob.Blob{
err := Ctl.Touch(ctx, &pkg_blob.Blob{
Status: models.StatusNone,
})
suite.NotNil(err)
@ -333,7 +332,7 @@ func (suite *ControllerTestSuite) TestTouch() {
func (suite *ControllerTestSuite) TestFail() {
ctx := suite.Context()
err := Ctl.Fail(ctx, &blob.Blob{
err := Ctl.Fail(ctx, &pkg_blob.Blob{
Status: models.StatusNone,
})
suite.NotNil(err)

View File

@ -22,7 +22,6 @@ import (
"github.com/goharbor/harbor/src/common"
testDao "github.com/goharbor/harbor/src/common/dao"
_ "github.com/goharbor/harbor/src/common/dao"
"github.com/goharbor/harbor/src/lib/orm"
"github.com/goharbor/harbor/src/pkg"
"github.com/goharbor/harbor/src/pkg/member/models"

View File

@ -10,7 +10,6 @@ import (
"github.com/goharbor/harbor/src/lib/q"
dao "github.com/goharbor/harbor/src/pkg/p2p/preheat/dao/instance"
"github.com/goharbor/harbor/src/pkg/p2p/preheat/models/provider"
providerModel "github.com/goharbor/harbor/src/pkg/p2p/preheat/models/provider"
)
@ -23,30 +22,30 @@ var lists = []*providerModel.Instance{
{Name: "abc"},
}
func (d *fakeDao) Create(ctx context.Context, instance *provider.Instance) (int64, error) {
func (d *fakeDao) Create(ctx context.Context, instance *providerModel.Instance) (int64, error) {
var args = d.Called()
return int64(args.Int(0)), args.Error(1)
}
func (d *fakeDao) Get(ctx context.Context, id int64) (*provider.Instance, error) {
func (d *fakeDao) Get(ctx context.Context, id int64) (*providerModel.Instance, error) {
var args = d.Called()
var instance *provider.Instance
var instance *providerModel.Instance
if args.Get(0) != nil {
instance = args.Get(0).(*provider.Instance)
instance = args.Get(0).(*providerModel.Instance)
}
return instance, args.Error(1)
}
func (d *fakeDao) GetByName(ctx context.Context, name string) (*provider.Instance, error) {
func (d *fakeDao) GetByName(ctx context.Context, name string) (*providerModel.Instance, error) {
var args = d.Called()
var instance *provider.Instance
var instance *providerModel.Instance
if args.Get(0) != nil {
instance = args.Get(0).(*provider.Instance)
instance = args.Get(0).(*providerModel.Instance)
}
return instance, args.Error(1)
}
func (d *fakeDao) Update(ctx context.Context, instance *provider.Instance, props ...string) error {
func (d *fakeDao) Update(ctx context.Context, instance *providerModel.Instance, props ...string) error {
var args = d.Called()
return args.Error(0)
}
@ -62,11 +61,11 @@ func (d *fakeDao) Count(ctx context.Context, query *q.Query) (total int64, err e
return int64(args.Int(0)), args.Error(1)
}
func (d *fakeDao) List(ctx context.Context, query *q.Query) (ins []*provider.Instance, err error) {
func (d *fakeDao) List(ctx context.Context, query *q.Query) (ins []*providerModel.Instance, err error) {
var args = d.Called()
var instances []*provider.Instance
var instances []*providerModel.Instance
if args.Get(0) != nil {
instances = args.Get(0).([]*provider.Instance)
instances = args.Get(0).([]*providerModel.Instance)
}
return instances, args.Error(1)
}

View File

@ -15,7 +15,6 @@ import (
"github.com/goharbor/harbor/src/lib/q"
"github.com/goharbor/harbor/src/pkg"
"github.com/goharbor/harbor/src/pkg/accessory"
"github.com/goharbor/harbor/src/pkg/accessory/model"
accessorymodel "github.com/goharbor/harbor/src/pkg/accessory/model"
_ "github.com/goharbor/harbor/src/pkg/accessory/model/base"
_ "github.com/goharbor/harbor/src/pkg/accessory/model/cosign"
@ -153,7 +152,7 @@ func (suite *MiddlewareTestSuite) TestCosignSignature() {
suite.Equal(artID, accs[0].GetData().ArtifactID)
suite.Equal(name, accs[0].GetData().SubArtifactRepo)
suite.True(accs[0].IsHard())
suite.Equal(model.TypeCosignSignature, accs[0].GetData().Type)
suite.Equal(accessorymodel.TypeCosignSignature, accs[0].GetData().Type)
})
}
@ -181,7 +180,7 @@ func (suite *MiddlewareTestSuite) TestCosignSignatureDup() {
suite.Equal(1, len(accs))
suite.Equal(descriptor.Digest.String(), accs[0].GetData().Digest)
suite.True(accs[0].IsHard())
suite.Equal(model.TypeCosignSignature, accs[0].GetData().Type)
suite.Equal(accessorymodel.TypeCosignSignature, accs[0].GetData().Type)
})
}

View File

@ -15,7 +15,6 @@ import (
"github.com/goharbor/harbor/src/lib/q"
"github.com/goharbor/harbor/src/pkg"
"github.com/goharbor/harbor/src/pkg/accessory"
"github.com/goharbor/harbor/src/pkg/accessory/model"
accessorymodel "github.com/goharbor/harbor/src/pkg/accessory/model"
_ "github.com/goharbor/harbor/src/pkg/accessory/model/base"
_ "github.com/goharbor/harbor/src/pkg/accessory/model/nydus"
@ -172,7 +171,7 @@ func (suite *MiddlewareTestSuite) TestNydusAccelerator() {
suite.Equal(subArtDigest, accs[0].GetData().SubArtifactDigest)
suite.Equal(artID, accs[0].GetData().ArtifactID)
suite.True(accs[0].IsHard())
suite.Equal(model.TypeNydusAccelerator, accs[0].GetData().Type)
suite.Equal(accessorymodel.TypeNydusAccelerator, accs[0].GetData().Type)
})
}
@ -199,7 +198,7 @@ func (suite *MiddlewareTestSuite) TestNydusAcceleratorDup() {
suite.Equal(1, len(accs))
suite.Equal(descriptor.Digest.String(), accs[0].GetData().Digest)
suite.True(accs[0].IsHard())
suite.Equal(model.TypeNydusAccelerator, accs[0].GetData().Type)
suite.Equal(accessorymodel.TypeNydusAccelerator, accs[0].GetData().Type)
})
}

View File

@ -15,7 +15,6 @@ import (
"github.com/goharbor/harbor/src/lib/q"
"github.com/goharbor/harbor/src/pkg"
"github.com/goharbor/harbor/src/pkg/accessory"
"github.com/goharbor/harbor/src/pkg/accessory/model"
accessorymodel "github.com/goharbor/harbor/src/pkg/accessory/model"
_ "github.com/goharbor/harbor/src/pkg/accessory/model/base"
_ "github.com/goharbor/harbor/src/pkg/accessory/model/cosign"
@ -159,7 +158,7 @@ func (suite *MiddlewareTestSuite) TestSubject() {
suite.Equal(artID, accs[0].GetData().ArtifactID)
suite.Equal(name, accs[0].GetData().SubArtifactRepo)
suite.True(accs[0].IsHard())
suite.Equal(model.TypeSubject, accs[0].GetData().Type)
suite.Equal(accessorymodel.TypeSubject, accs[0].GetData().Type)
})
}
@ -187,7 +186,7 @@ func (suite *MiddlewareTestSuite) TestSubjectDup() {
suite.Equal(1, len(accs))
suite.Equal(descriptor.Digest.String(), accs[0].GetData().Digest)
suite.True(accs[0].IsHard())
suite.Equal(model.TypeSubject, accs[0].GetData().Type)
suite.Equal(accessorymodel.TypeSubject, accs[0].GetData().Type)
})
}