From 73f3a305cec069c563452052bcfdcb3ad559bd46 Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Thu, 26 Mar 2020 14:00:11 +0800 Subject: [PATCH] refactor: rename testing/api to testing/controller (#11295) Signed-off-by: He Weiwei --- src/controller/artifact/controller_test.go | 2 +- .../event/handler/webhook/scan/scan_test.go | 4 ++-- .../quota/driver/project/project_test.go | 6 ++--- src/controller/quota/util_test.go | 2 +- src/controller/repository/controller_test.go | 2 +- src/controller/scan/base_controller_test.go | 4 ++-- src/controller/scan/checker_test.go | 4 ++-- src/core/api/pro_scanner_test.go | 2 +- src/core/api/scanners_test.go | 2 +- src/server/middleware/quota/quota_test.go | 8 +++---- src/server/middleware/quota/util_test.go | 2 +- .../middleware/vulnerable/vulnerable_test.go | 6 ++--- src/server/registry/catalog_test.go | 2 +- src/server/registry/manifest_test.go | 4 ++-- src/server/registry/tag_test.go | 4 ++-- src/server/v2.0/handler/assembler/vul_test.go | 2 +- src/testing/api/api.go | 24 ------------------- .../artifact/controller.go | 0 .../{api => controller}/blob/controller.go | 0 .../chartmuseum/controller.go | 0 src/testing/controller/controller.go | 24 +++++++++++++++++++ .../{api => controller}/project/controller.go | 0 .../{api => controller}/quota/controller.go | 0 .../repository/controller.go | 0 .../{api => controller}/scan/checker.go | 0 .../{api => controller}/scan/controller.go | 0 .../{api => controller}/scanner/controller.go | 8 +++---- .../{api => controller}/tag/controller.go | 0 28 files changed, 56 insertions(+), 56 deletions(-) delete mode 100644 src/testing/api/api.go rename src/testing/{api => controller}/artifact/controller.go (100%) rename src/testing/{api => controller}/blob/controller.go (100%) rename src/testing/{api => controller}/chartmuseum/controller.go (100%) create mode 100644 src/testing/controller/controller.go rename src/testing/{api => controller}/project/controller.go (100%) rename src/testing/{api => controller}/quota/controller.go (100%) rename src/testing/{api => controller}/repository/controller.go (100%) rename src/testing/{api => controller}/scan/checker.go (100%) rename src/testing/{api => controller}/scan/controller.go (100%) rename src/testing/{api => controller}/scanner/controller.go (94%) rename src/testing/{api => controller}/tag/controller.go (100%) diff --git a/src/controller/artifact/controller_test.go b/src/controller/artifact/controller_test.go index 60906f5b0..15711de6d 100644 --- a/src/controller/artifact/controller_test.go +++ b/src/controller/artifact/controller_test.go @@ -27,7 +27,7 @@ import ( "github.com/goharbor/harbor/src/lib/q" "github.com/goharbor/harbor/src/pkg/artifact" model_tag "github.com/goharbor/harbor/src/pkg/tag/model/tag" - tagtesting "github.com/goharbor/harbor/src/testing/api/tag" + tagtesting "github.com/goharbor/harbor/src/testing/controller/tag" ormtesting "github.com/goharbor/harbor/src/testing/lib/orm" arttesting "github.com/goharbor/harbor/src/testing/pkg/artifact" artrashtesting "github.com/goharbor/harbor/src/testing/pkg/artifactrash" diff --git a/src/controller/event/handler/webhook/scan/scan_test.go b/src/controller/event/handler/webhook/scan/scan_test.go index e293570fa..b57ffe6a7 100644 --- a/src/controller/event/handler/webhook/scan/scan_test.go +++ b/src/controller/event/handler/webhook/scan/scan_test.go @@ -31,8 +31,8 @@ import ( "github.com/goharbor/harbor/src/pkg/scan/dao/scan" "github.com/goharbor/harbor/src/pkg/scan/report" v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" - scantesting "github.com/goharbor/harbor/src/testing/api/scan" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + scantesting "github.com/goharbor/harbor/src/testing/controller/scan" "github.com/goharbor/harbor/src/testing/mock" notificationtesting "github.com/goharbor/harbor/src/testing/pkg/notification" "github.com/stretchr/testify/require" diff --git a/src/controller/quota/driver/project/project_test.go b/src/controller/quota/driver/project/project_test.go index b76cfec6b..72b4a1413 100644 --- a/src/controller/quota/driver/project/project_test.go +++ b/src/controller/quota/driver/project/project_test.go @@ -19,9 +19,9 @@ import ( "testing" "github.com/goharbor/harbor/src/pkg/types" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" - blobtesting "github.com/goharbor/harbor/src/testing/api/blob" - charttesting "github.com/goharbor/harbor/src/testing/api/chartmuseum" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + blobtesting "github.com/goharbor/harbor/src/testing/controller/blob" + charttesting "github.com/goharbor/harbor/src/testing/controller/chartmuseum" "github.com/goharbor/harbor/src/testing/mock" "github.com/stretchr/testify/suite" ) diff --git a/src/controller/quota/util_test.go b/src/controller/quota/util_test.go index 0835192a5..1480c6b6c 100644 --- a/src/controller/quota/util_test.go +++ b/src/controller/quota/util_test.go @@ -26,7 +26,7 @@ import ( "github.com/goharbor/harbor/src/pkg/quota" "github.com/goharbor/harbor/src/pkg/quota/driver" "github.com/goharbor/harbor/src/pkg/types" - projecttesting "github.com/goharbor/harbor/src/testing/api/project" + projecttesting "github.com/goharbor/harbor/src/testing/controller/project" ormtesting "github.com/goharbor/harbor/src/testing/lib/orm" "github.com/goharbor/harbor/src/testing/mock" quotatesting "github.com/goharbor/harbor/src/testing/pkg/quota" diff --git a/src/controller/repository/controller_test.go b/src/controller/repository/controller_test.go index 0dd75bd37..732c64214 100644 --- a/src/controller/repository/controller_test.go +++ b/src/controller/repository/controller_test.go @@ -19,7 +19,7 @@ import ( "github.com/goharbor/harbor/src/controller/artifact" ierror "github.com/goharbor/harbor/src/lib/error" "github.com/goharbor/harbor/src/lib/orm" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" ormtesting "github.com/goharbor/harbor/src/testing/lib/orm" "github.com/goharbor/harbor/src/testing/mock" arttesting "github.com/goharbor/harbor/src/testing/pkg/artifact" diff --git a/src/controller/scan/base_controller_test.go b/src/controller/scan/base_controller_test.go index a1d6f7e81..595836926 100644 --- a/src/controller/scan/base_controller_test.go +++ b/src/controller/scan/base_controller_test.go @@ -36,8 +36,8 @@ import ( "github.com/goharbor/harbor/src/pkg/scan/dao/scanner" v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1" "github.com/goharbor/harbor/src/pkg/scan/vuln" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" - scannertesting "github.com/goharbor/harbor/src/testing/api/scanner" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + scannertesting "github.com/goharbor/harbor/src/testing/controller/scanner" mocktesting "github.com/goharbor/harbor/src/testing/mock" reporttesting "github.com/goharbor/harbor/src/testing/pkg/scan/report" "github.com/stretchr/testify/assert" diff --git a/src/controller/scan/checker_test.go b/src/controller/scan/checker_test.go index 5fc413871..407e08a01 100644 --- a/src/controller/scan/checker_test.go +++ b/src/controller/scan/checker_test.go @@ -21,8 +21,8 @@ import ( "github.com/goharbor/harbor/src/controller/artifact" "github.com/goharbor/harbor/src/pkg/scan/dao/scanner" v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" - scannertesting "github.com/goharbor/harbor/src/testing/api/scanner" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + scannertesting "github.com/goharbor/harbor/src/testing/controller/scanner" "github.com/goharbor/harbor/src/testing/mock" "github.com/stretchr/testify/suite" ) diff --git a/src/core/api/pro_scanner_test.go b/src/core/api/pro_scanner_test.go index 1901f1b3a..58e96242e 100644 --- a/src/core/api/pro_scanner_test.go +++ b/src/core/api/pro_scanner_test.go @@ -22,7 +22,7 @@ import ( sc "github.com/goharbor/harbor/src/controller/scanner" "github.com/goharbor/harbor/src/lib/q" "github.com/goharbor/harbor/src/pkg/scan/dao/scanner" - scannertesting "github.com/goharbor/harbor/src/testing/api/scanner" + scannertesting "github.com/goharbor/harbor/src/testing/controller/scanner" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" diff --git a/src/core/api/scanners_test.go b/src/core/api/scanners_test.go index 4fd7dbae5..429ec625e 100644 --- a/src/core/api/scanners_test.go +++ b/src/core/api/scanners_test.go @@ -22,7 +22,7 @@ import ( sc "github.com/goharbor/harbor/src/controller/scanner" "github.com/goharbor/harbor/src/lib/q" "github.com/goharbor/harbor/src/pkg/scan/dao/scanner" - scannertesting "github.com/goharbor/harbor/src/testing/api/scanner" + scannertesting "github.com/goharbor/harbor/src/testing/controller/scanner" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" diff --git a/src/server/middleware/quota/quota_test.go b/src/server/middleware/quota/quota_test.go index d1bbb9bc6..b04f6f6da 100644 --- a/src/server/middleware/quota/quota_test.go +++ b/src/server/middleware/quota/quota_test.go @@ -26,10 +26,10 @@ import ( "github.com/goharbor/harbor/src/controller/project" "github.com/goharbor/harbor/src/controller/quota" "github.com/goharbor/harbor/src/pkg/types" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" - blobtesting "github.com/goharbor/harbor/src/testing/api/blob" - projecttesting "github.com/goharbor/harbor/src/testing/api/project" - quotatesting "github.com/goharbor/harbor/src/testing/api/quota" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + blobtesting "github.com/goharbor/harbor/src/testing/controller/blob" + projecttesting "github.com/goharbor/harbor/src/testing/controller/project" + quotatesting "github.com/goharbor/harbor/src/testing/controller/quota" "github.com/goharbor/harbor/src/testing/mock" "github.com/stretchr/testify/suite" ) diff --git a/src/server/middleware/quota/util_test.go b/src/server/middleware/quota/util_test.go index 9c14a683e..20a8f3679 100644 --- a/src/server/middleware/quota/util_test.go +++ b/src/server/middleware/quota/util_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/goharbor/harbor/src/common/models" - "github.com/goharbor/harbor/src/testing/api/project" + "github.com/goharbor/harbor/src/testing/controller/project" "github.com/stretchr/testify/mock" ) diff --git a/src/server/middleware/vulnerable/vulnerable_test.go b/src/server/middleware/vulnerable/vulnerable_test.go index 818db6240..b3d996cea 100644 --- a/src/server/middleware/vulnerable/vulnerable_test.go +++ b/src/server/middleware/vulnerable/vulnerable_test.go @@ -29,10 +29,10 @@ import ( "github.com/goharbor/harbor/src/lib" v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1" "github.com/goharbor/harbor/src/pkg/scan/vuln" - artifacttesting "github.com/goharbor/harbor/src/testing/api/artifact" - projecttesting "github.com/goharbor/harbor/src/testing/api/project" - scantesting "github.com/goharbor/harbor/src/testing/api/scan" securitytesting "github.com/goharbor/harbor/src/testing/common/security" + artifacttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + projecttesting "github.com/goharbor/harbor/src/testing/controller/project" + scantesting "github.com/goharbor/harbor/src/testing/controller/scan" "github.com/goharbor/harbor/src/testing/mock" "github.com/stretchr/testify/suite" ) diff --git a/src/server/registry/catalog_test.go b/src/server/registry/catalog_test.go index 6494a3205..26d3637f2 100644 --- a/src/server/registry/catalog_test.go +++ b/src/server/registry/catalog_test.go @@ -18,7 +18,7 @@ import ( "encoding/json" "github.com/goharbor/harbor/src/common/models" "github.com/goharbor/harbor/src/controller/repository" - repotesting "github.com/goharbor/harbor/src/testing/api/repository" + repotesting "github.com/goharbor/harbor/src/testing/controller/repository" "github.com/stretchr/testify/suite" "net/http" "net/http/httptest" diff --git a/src/server/registry/manifest_test.go b/src/server/registry/manifest_test.go index 8fa5927ea..07ac5cdc0 100644 --- a/src/server/registry/manifest_test.go +++ b/src/server/registry/manifest_test.go @@ -25,8 +25,8 @@ import ( "github.com/goharbor/harbor/src/controller/artifact" "github.com/goharbor/harbor/src/controller/repository" ierror "github.com/goharbor/harbor/src/lib/error" - arttesting "github.com/goharbor/harbor/src/testing/api/artifact" - repotesting "github.com/goharbor/harbor/src/testing/api/repository" + arttesting "github.com/goharbor/harbor/src/testing/controller/artifact" + repotesting "github.com/goharbor/harbor/src/testing/controller/repository" "github.com/goharbor/harbor/src/testing/mock" "github.com/stretchr/testify/suite" ) diff --git a/src/server/registry/tag_test.go b/src/server/registry/tag_test.go index c16283c00..e27e20ae7 100644 --- a/src/server/registry/tag_test.go +++ b/src/server/registry/tag_test.go @@ -20,8 +20,8 @@ import ( "github.com/goharbor/harbor/src/controller/repository" "github.com/goharbor/harbor/src/controller/tag" model_tag "github.com/goharbor/harbor/src/pkg/tag/model/tag" - repotesting "github.com/goharbor/harbor/src/testing/api/repository" - tagtesting "github.com/goharbor/harbor/src/testing/api/tag" + repotesting "github.com/goharbor/harbor/src/testing/controller/repository" + tagtesting "github.com/goharbor/harbor/src/testing/controller/tag" "github.com/stretchr/testify/suite" "net/http" "net/http/httptest" diff --git a/src/server/v2.0/handler/assembler/vul_test.go b/src/server/v2.0/handler/assembler/vul_test.go index a8a26f178..a43f6f4f1 100644 --- a/src/server/v2.0/handler/assembler/vul_test.go +++ b/src/server/v2.0/handler/assembler/vul_test.go @@ -19,7 +19,7 @@ import ( "testing" "github.com/goharbor/harbor/src/server/v2.0/handler/model" - "github.com/goharbor/harbor/src/testing/api/scan" + "github.com/goharbor/harbor/src/testing/controller/scan" "github.com/goharbor/harbor/src/testing/mock" "github.com/stretchr/testify/suite" ) diff --git a/src/testing/api/api.go b/src/testing/api/api.go deleted file mode 100644 index badd2e880..000000000 --- a/src/testing/api/api.go +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -package api - -//go:generate mockery -case snake -dir ../../api/artifact -name Controller -output ./artifact -outpkg artifact -//go:generate mockery -case snake -dir ../../api/blob -name Controller -output ./blob -outpkg blob -//go:generate mockery -case snake -dir ../../api/chartmuseum -name Controller -output ./chartmuseum -outpkg chartmuseum -//go:generate mockery -case snake -dir ../../api/project -name Controller -output ./project -outpkg project -//go:generate mockery -case snake -dir ../../api/quota -name Controller -output ./quota -outpkg quota -//go:generate mockery -case snake -dir ../../api/scan -name Controller -output ./scan -outpkg scan -//go:generate mockery -case snake -dir ../../api/scan -name Checker -output ./scan -outpkg scan -//go:generate mockery -case snake -dir ../../api/scanner -name Controller -output ./scanner -outpkg scanner diff --git a/src/testing/api/artifact/controller.go b/src/testing/controller/artifact/controller.go similarity index 100% rename from src/testing/api/artifact/controller.go rename to src/testing/controller/artifact/controller.go diff --git a/src/testing/api/blob/controller.go b/src/testing/controller/blob/controller.go similarity index 100% rename from src/testing/api/blob/controller.go rename to src/testing/controller/blob/controller.go diff --git a/src/testing/api/chartmuseum/controller.go b/src/testing/controller/chartmuseum/controller.go similarity index 100% rename from src/testing/api/chartmuseum/controller.go rename to src/testing/controller/chartmuseum/controller.go diff --git a/src/testing/controller/controller.go b/src/testing/controller/controller.go new file mode 100644 index 000000000..0a062997a --- /dev/null +++ b/src/testing/controller/controller.go @@ -0,0 +1,24 @@ +// 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. + +package controller + +//go:generate mockery -case snake -dir ../../controller/artifact -name Controller -output ./artifact -outpkg artifact +//go:generate mockery -case snake -dir ../../controller/blob -name Controller -output ./blob -outpkg blob +//go:generate mockery -case snake -dir ../../controller/chartmuseum -name Controller -output ./chartmuseum -outpkg chartmuseum +//go:generate mockery -case snake -dir ../../controller/project -name Controller -output ./project -outpkg project +//go:generate mockery -case snake -dir ../../controller/quota -name Controller -output ./quota -outpkg quota +//go:generate mockery -case snake -dir ../../controller/scan -name Controller -output ./scan -outpkg scan +//go:generate mockery -case snake -dir ../../controller/scan -name Checker -output ./scan -outpkg scan +//go:generate mockery -case snake -dir ../../controller/scanner -name Controller -output ./scanner -outpkg scanner diff --git a/src/testing/api/project/controller.go b/src/testing/controller/project/controller.go similarity index 100% rename from src/testing/api/project/controller.go rename to src/testing/controller/project/controller.go diff --git a/src/testing/api/quota/controller.go b/src/testing/controller/quota/controller.go similarity index 100% rename from src/testing/api/quota/controller.go rename to src/testing/controller/quota/controller.go diff --git a/src/testing/api/repository/controller.go b/src/testing/controller/repository/controller.go similarity index 100% rename from src/testing/api/repository/controller.go rename to src/testing/controller/repository/controller.go diff --git a/src/testing/api/scan/checker.go b/src/testing/controller/scan/checker.go similarity index 100% rename from src/testing/api/scan/checker.go rename to src/testing/controller/scan/checker.go diff --git a/src/testing/api/scan/controller.go b/src/testing/controller/scan/controller.go similarity index 100% rename from src/testing/api/scan/controller.go rename to src/testing/controller/scan/controller.go diff --git a/src/testing/api/scanner/controller.go b/src/testing/controller/scanner/controller.go similarity index 94% rename from src/testing/api/scanner/controller.go rename to src/testing/controller/scanner/controller.go index 6fd232007..3d5af1342 100644 --- a/src/testing/api/scanner/controller.go +++ b/src/testing/controller/scanner/controller.go @@ -3,7 +3,7 @@ package scanner import ( - apiscanner "github.com/goharbor/harbor/src/controller/scanner" + controllerscanner "github.com/goharbor/harbor/src/controller/scanner" mock "github.com/stretchr/testify/mock" q "github.com/goharbor/harbor/src/lib/q" @@ -109,7 +109,7 @@ func (_m *Controller) GetRegistration(registrationUUID string) (*scanner.Registr } // GetRegistrationByProject provides a mock function with given fields: projectID, options -func (_m *Controller) GetRegistrationByProject(projectID int64, options ...apiscanner.Option) (*scanner.Registration, error) { +func (_m *Controller) GetRegistrationByProject(projectID int64, options ...controllerscanner.Option) (*scanner.Registration, error) { _va := make([]interface{}, len(options)) for _i := range options { _va[_i] = options[_i] @@ -120,7 +120,7 @@ func (_m *Controller) GetRegistrationByProject(projectID int64, options ...apisc ret := _m.Called(_ca...) var r0 *scanner.Registration - if rf, ok := ret.Get(0).(func(int64, ...apiscanner.Option) *scanner.Registration); ok { + if rf, ok := ret.Get(0).(func(int64, ...controllerscanner.Option) *scanner.Registration); ok { r0 = rf(projectID, options...) } else { if ret.Get(0) != nil { @@ -129,7 +129,7 @@ func (_m *Controller) GetRegistrationByProject(projectID int64, options ...apisc } var r1 error - if rf, ok := ret.Get(1).(func(int64, ...apiscanner.Option) error); ok { + if rf, ok := ret.Get(1).(func(int64, ...controllerscanner.Option) error); ok { r1 = rf(projectID, options...) } else { r1 = ret.Error(1) diff --git a/src/testing/api/tag/controller.go b/src/testing/controller/tag/controller.go similarity index 100% rename from src/testing/api/tag/controller.go rename to src/testing/controller/tag/controller.go