[Cmii][ImageSync] -Image Function accomplish -1
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user