MCPcopy Index your code
hub / github.com/containerd/containerd / TestUseDescriptorData

Function TestUseDescriptorData

core/content/helpers_test.go:240–362  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

238}
239
240func TestUseDescriptorData(t *testing.T) {
241 helloData := []byte("hello")
242 helloDigest := digest.FromBytes(helloData)
243 helloSHA512 := digest.SHA512.FromBytes(helloData)
244
245 tests := []struct {
246 name string
247 desc ocispec.Descriptor
248 wantUse bool
249 wantErrorIs error
250 }{
251 {
252 name: "valid data with matching size and sha256 digest",
253 desc: ocispec.Descriptor{
254 Data: helloData,
255 Size: int64(len(helloData)),
256 Digest: helloDigest,
257 },
258 wantUse: true,
259 },
260 {
261 name: "valid data with matching size and sha512 digest",
262 desc: ocispec.Descriptor{
263 Data: helloData,
264 Size: int64(len(helloData)),
265 Digest: helloSHA512,
266 },
267 wantUse: true,
268 },
269 {
270 name: "nil data with zero size and valid empty digest",
271 desc: ocispec.Descriptor{
272 Data: nil,
273 Size: 0,
274 Digest: digest.FromBytes(nil),
275 },
276 wantUse: true,
277 },
278 {
279 name: "size mismatch data longer than size",
280 desc: ocispec.Descriptor{
281 Data: helloData,
282 Size: 3,
283 Digest: helloDigest,
284 },
285 wantUse: false,
286 },
287 {
288 name: "size mismatch data shorter than size",
289 desc: ocispec.Descriptor{
290 Data: []byte("hi"),
291 Size: 10,
292 Digest: helloDigest,
293 },
294 wantUse: false,
295 },
296 {
297 name: "nil data with non-zero size",

Callers

nothing calls this directly

Calls 3

useDescriptorDataFunction · 0.85
DigestMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…