Merge pull request #10105 from fidencio/topic/fix-typos-in-image_pull_test.go

images: tests: Fix typos in the tests
This commit is contained in:
Kazuyoshi Kato 2024-05-17 01:27:46 +00:00 committed by GitHub
commit ff66ec7a73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -378,29 +378,29 @@ func TestDefaultScheme(t *testing.T) {
//}
func TestSnapshotterFromPodSandboxConfig(t *testing.T) {
defaultSnashotter := "native"
defaultSnapshotter := "native"
runtimeSnapshotter := "devmapper"
tests := []struct {
desc string
podSandboxConfig *runtime.PodSandboxConfig
expectSnapshotter string
expectErr bool
expectedSnapshotter string
expectedErr bool
}{
{
desc: "should return default snapshotter for nil podSandboxConfig",
expectSnapshotter: defaultSnashotter,
expectedSnapshotter: defaultSnapshotter,
},
{
desc: "should return default snapshotter for nil podSandboxConfig.Annotations",
podSandboxConfig: &runtime.PodSandboxConfig{},
expectSnapshotter: defaultSnashotter,
expectedSnapshotter: defaultSnapshotter,
},
{
desc: "should return default snapshotter for empty podSandboxConfig.Annotations",
podSandboxConfig: &runtime.PodSandboxConfig{
Annotations: make(map[string]string),
},
expectSnapshotter: defaultSnashotter,
expectedSnapshotter: defaultSnapshotter,
},
{
desc: "should return default snapshotter for runtime not found",
@ -409,30 +409,30 @@ func TestSnapshotterFromPodSandboxConfig(t *testing.T) {
annotations.RuntimeHandler: "runtime-not-exists",
},
},
expectSnapshotter: defaultSnashotter,
expectedSnapshotter: defaultSnapshotter,
},
{
desc: "should return snapshotter provided in podSandboxConfig.Annotations",
podSandboxConfig: &runtime.PodSandboxConfig{
Annotations: map[string]string{
annotations.RuntimeHandler: "exiting-runtime",
annotations.RuntimeHandler: "existing-runtime",
},
},
expectSnapshotter: runtimeSnapshotter,
expectedSnapshotter: runtimeSnapshotter,
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
cri, _ := newTestCRIService()
cri.config.Snapshotter = defaultSnashotter
cri.runtimePlatforms["exiting-runtime"] = ImagePlatform{
cri.config.Snapshotter = defaultSnapshotter
cri.runtimePlatforms["existing-runtime"] = ImagePlatform{
Platform: platforms.DefaultSpec(),
Snapshotter: runtimeSnapshotter,
}
snapshotter, err := cri.snapshotterFromPodSandboxConfig(context.Background(), "test-image", tt.podSandboxConfig)
assert.Equal(t, tt.expectSnapshotter, snapshotter)
if tt.expectErr {
assert.Equal(t, tt.expectedSnapshotter, snapshotter)
if tt.expectedErr {
assert.Error(t, err)
}
})