MCPcopy
hub / github.com/containerd/containerd / TestImport

Function TestImport

integration/client/import_test.go:151–466  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestImport(t *testing.T) {
152 ctx, cancel := testContext(t)
153 defer cancel()
154
155 tc := tartest.TarContext{}
156
157 b1, d1 := createContent(256, 1)
158 empty := []byte("{}")
159 version := []byte("1.0")
160
161 c1, d2 := createConfig(runtime.GOOS, runtime.GOARCH, "test")
162 badConfig, _ := createConfig("foo", "lish", "test")
163
164 m1, d3, expManifest := createManifest(c1, [][]byte{b1})
165
166 importLabels := map[string]string{"foo": "bar"}
167
168 c2, _ := createConfig(runtime.GOOS, runtime.GOARCH, "test2")
169 m2, d5, _ := createManifest(c2, [][]byte{{1, 2, 3, 4, 5}})
170
171 ml1, d6 := createManifestList(m1, m2)
172
173 checkManifest := func(ctx context.Context, t *testing.T, provider content.Provider, d ocispec.Descriptor, expManifest *ocispec.Manifest) {
174 m, err := images.Manifest(ctx, provider, d, nil)
175 if err != nil {
176 t.Fatalf("unable to read target blob: %+v", err)
177 }
178
179 if m.Config.Digest != d2 {
180 t.Fatalf("unexpected digest hash %s, expected %s", m.Config.Digest, d2)
181 }
182
183 if len(m.Layers) != 1 {
184 t.Fatalf("expected 1 layer, has %d", len(m.Layers))
185 }
186
187 if m.Layers[0].Digest != d1 {
188 t.Fatalf("unexpected layer hash %s, expected %s", m.Layers[0].Digest, d1)
189 }
190
191 if expManifest != nil {
192 if !reflect.DeepEqual(m.Layers, expManifest.Layers) {
193 t.Fatalf("DeepEqual on Layers failed: %v vs. %v", m.Layers, expManifest.Layers)
194 }
195 if !reflect.DeepEqual(m.Config, expManifest.Config) {
196 t.Fatalf("DeepEqual on Config failed: %v vs. %v", m.Config, expManifest.Config)
197 }
198 }
199 }
200
201 for _, tc := range []struct {
202 Name string
203 Writer tartest.WriterToTar
204 Check func(context.Context, *testing.T, *Client, []images.Image)
205 Opts []ImportOpt
206 }{
207 {
208 Name: "OCI-IndexWithoutAnyManifest",

Callers

nothing calls this directly

Calls 15

DirMethod · 0.95
FileMethod · 0.95
ManifestFunction · 0.92
TarAllFunction · 0.92
ChildrenFunction · 0.92
ExistsFunction · 0.92
CheckFunction · 0.92
WithNamespaceFunction · 0.92
TarFromWriterToFunction · 0.92
testContextFunction · 0.85
createConfigFunction · 0.85
createManifestFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…