2022-03-25 10:59:37 +01:00
|
|
|
// 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 pkg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/goharbor/harbor/src/pkg/artifact"
|
2022-05-05 10:36:49 +02:00
|
|
|
cachedArtifact "github.com/goharbor/harbor/src/pkg/cached/artifact/redis"
|
|
|
|
cachedProject "github.com/goharbor/harbor/src/pkg/cached/project/redis"
|
2022-05-06 09:15:18 +02:00
|
|
|
cachedRepo "github.com/goharbor/harbor/src/pkg/cached/repository/redis"
|
2022-05-05 10:36:49 +02:00
|
|
|
"github.com/goharbor/harbor/src/pkg/project"
|
2022-05-06 09:15:18 +02:00
|
|
|
"github.com/goharbor/harbor/src/pkg/repository"
|
2022-03-25 10:59:37 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-05-05 10:36:49 +02:00
|
|
|
func TestInitArtifactMgr(t *testing.T) {
|
2022-03-25 10:59:37 +01:00
|
|
|
// cache not enable
|
|
|
|
assert.NotNil(t, ArtifactMgr)
|
|
|
|
assert.IsType(t, artifact.NewManager(), ArtifactMgr)
|
|
|
|
|
|
|
|
// cache enable
|
2022-05-05 10:36:49 +02:00
|
|
|
initArtifactMgr(true)
|
2022-03-25 10:59:37 +01:00
|
|
|
assert.NotNil(t, ArtifactMgr)
|
2022-05-05 10:36:49 +02:00
|
|
|
assert.IsType(t, cachedArtifact.NewManager(artifact.NewManager()), ArtifactMgr)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInitProjectMgr(t *testing.T) {
|
|
|
|
// cache not enable
|
|
|
|
assert.NotNil(t, ProjectMgr)
|
|
|
|
assert.IsType(t, project.New(), ProjectMgr)
|
|
|
|
|
|
|
|
// cache enable
|
|
|
|
initProjectMgr(true)
|
|
|
|
assert.NotNil(t, ProjectMgr)
|
|
|
|
assert.IsType(t, cachedProject.NewManager(project.New()), ProjectMgr)
|
2022-03-25 10:59:37 +01:00
|
|
|
}
|
2022-05-06 09:15:18 +02:00
|
|
|
|
|
|
|
func TestInitRepositoryMgr(t *testing.T) {
|
|
|
|
// cache not enable
|
|
|
|
assert.NotNil(t, RepositoryMgr)
|
|
|
|
assert.IsType(t, repository.New(), RepositoryMgr)
|
|
|
|
|
|
|
|
// cache enable
|
|
|
|
initRepositoryMgr(true)
|
|
|
|
assert.NotNil(t, RepositoryMgr)
|
|
|
|
assert.IsType(t, cachedRepo.NewManager(repository.New()), RepositoryMgr)
|
|
|
|
}
|