[Cmii][ImageSync] -Image Function accomplish -1

This commit is contained in:
zeaslity
2024-03-26 17:17:46 +08:00
committed by zeaslity
parent d800d5dfb8
commit 2b53db2141
14 changed files with 245 additions and 52 deletions

View File

@@ -66,3 +66,43 @@ func TestBasicCommandExists(t *testing.T) {
t.Logf("command exists is => %s", strconv.FormatBool(exists))
}
func TestBasicDockerImageExistByFullName(t *testing.T) {
// Test cases
testCases := []struct {
name string
imageFullName string
expectedResult bool
}{
{
name: "Image exists with full name and version",
imageFullName: "harbor.cdcyy.com.cn/cmii/busybox:0326",
expectedResult: true,
},
{
name: "Image does not exist with full name and version",
imageFullName: "nonexistentImage:latest",
expectedResult: false,
},
{
name: "Image exists with full name but no version",
imageFullName: "harbor.cdcyy.com.cn/cmii/busybox",
expectedResult: true,
},
{
name: "Image does not exist with full name but no version",
imageFullName: "nonexistentImage",
expectedResult: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := BasicDockerImageExistByFullName(tc.imageFullName)
if result != tc.expectedResult {
t.Errorf("Expected %t for imageFullName %s, but got %t", tc.expectedResult, tc.imageFullName, result)
}
})
}
}