MCPcopy Create free account
hub / github.com/containerd/containerd / TestLoadBaseOCISpec

Function TestLoadBaseOCISpec

plugins/cri/runtime/load_test.go:32–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestLoadBaseOCISpec(t *testing.T) {
33 spec := oci.Spec{Version: "1.0.2", Hostname: "default"}
34
35 file, err := os.Create(filepath.Join(t.TempDir(), "spec-test-"))
36 require.NoError(t, err)
37 t.Cleanup(func() {
38 file.Close()
39 })
40
41 err = json.NewEncoder(file).Encode(&spec)
42 assert.NoError(t, err)
43
44 config := criconfig.Config{}
45 config.Runtimes = map[string]criconfig.Runtime{
46 "runc": {BaseRuntimeSpec: file.Name()},
47 }
48
49 specs, err := loadBaseOCISpecs(&config)
50 assert.NoError(t, err)
51
52 assert.Len(t, specs, 1)
53
54 out, ok := specs[file.Name()]
55 assert.True(t, ok, "expected spec with file name %q", file.Name())
56
57 assert.Equal(t, "1.0.2", out.Version)
58 assert.Equal(t, "default", out.Hostname)
59}

Callers

nothing calls this directly

Calls 6

loadBaseOCISpecsFunction · 0.85
CreateMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…