[ Cmii ] [ Operator ] - Harbor Operator
This commit is contained in:
96
agent-operator/image/HarborOperator_test.go
Normal file
96
agent-operator/image/HarborOperator_test.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"wdd.io/agent-common/utils"
|
||||
)
|
||||
|
||||
var DefaultHarborOperator *HarborOperator
|
||||
|
||||
func TestHarborOperator_BuildOperator(t *testing.T) {
|
||||
harborOperator := &HarborOperator{
|
||||
HarborHost: "http://harbor.wdd.io",
|
||||
HarborPort: "8033",
|
||||
HarborUser: "",
|
||||
HarborPass: "",
|
||||
HarborClient: nil,
|
||||
}
|
||||
|
||||
_, err := harborOperator.BuildOperator()
|
||||
if err != nil {
|
||||
t.Logf("error is %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
DefaultHarborOperator = harborOperator
|
||||
|
||||
}
|
||||
|
||||
func TestHarborOperator_RepoListAll(t *testing.T) {
|
||||
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
|
||||
repoListAll := DefaultHarborOperator.RepoListAll("cmii")
|
||||
|
||||
utils.BeautifulPrint(repoListAll)
|
||||
|
||||
}
|
||||
|
||||
func TestHarborOperator_RepoAllCmiiImage(t *testing.T) {
|
||||
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
|
||||
repoListAll := DefaultHarborOperator.RepoAllCmiiImage()
|
||||
|
||||
utils.BeautifulPrint(repoListAll)
|
||||
}
|
||||
|
||||
func TestHarborOperator_ArtifactListAll(t *testing.T) {
|
||||
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
|
||||
artifactListAll := DefaultHarborOperator.ArtifactListAll("cmii", "cmii-uav-user")
|
||||
|
||||
for _, artifact := range artifactListAll {
|
||||
for _, tag := range artifact.Tags {
|
||||
fmt.Println(tag.Name)
|
||||
}
|
||||
}
|
||||
utils.BeautifulPrint(artifactListAll)
|
||||
|
||||
}
|
||||
|
||||
func TestHarborOperator_ArtifactListOne(t *testing.T) {
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
|
||||
//reference := "sha256:0048162a053eef4d4ce3fe7518615bef084403614f8bca43b40ae2e762e11e06" // not ok icon
|
||||
reference := "sha256:27bd0055156abc20c29863750f13bbcc14019126da36d3941cfd82eb104ec31a" // ok digest
|
||||
// reference := "5.2.0" // ok tag
|
||||
artifactListOne := DefaultHarborOperator.ArtifactListOne("cmii", "cmii-uav-user", reference)
|
||||
|
||||
utils.BeautifulPrint(artifactListOne)
|
||||
}
|
||||
|
||||
func TestHarborOperator_ArtifactDeleteOne(t *testing.T) {
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
reference := "sha256:27bd0055156abc20c29863750f13bbcc14019126da36d3941cfd82eb104ec31a"
|
||||
ccc := DefaultHarborOperator.ArtifactDeleteOne("cmii", "cmii-uav-user", reference)
|
||||
if !ccc {
|
||||
log.Error("delete failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHarborOperator_CmiiTagFilter(t *testing.T) {
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
imageMap := DefaultHarborOperator.CmiiTagFilter("4")
|
||||
utils.BeautifulPrint(imageMap)
|
||||
}
|
||||
|
||||
func TestHarborOperator_ArtifactDeleteFromNameTagList(t *testing.T) {
|
||||
|
||||
TestHarborOperator_BuildOperator(t)
|
||||
allCmiiImageList := DefaultHarborOperator.CmiiTagFilter("5")
|
||||
errorDeleteList := DefaultHarborOperator.ArtifactDeleteFromNameTagList("cmii", allCmiiImageList)
|
||||
utils.BeautifulPrint(errorDeleteList)
|
||||
}
|
||||
Reference in New Issue
Block a user