From 2947ded7a8fced28fb3478f556194d12433145ad Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 19 Jan 2022 19:36:45 -0500 Subject: Don't segfault if an image layer has no creation timestamp It's optional in the specification, and I initially omitted it in the ostree code. Now I've fixed the ostree code to inject a timestamp, but we should clearly avoid segfaulting on this case. Signed-off-by: Colin Walters --- pkg/domain/infra/abi/images_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'pkg/domain/infra/abi/images_test.go') diff --git a/pkg/domain/infra/abi/images_test.go b/pkg/domain/infra/abi/images_test.go index 20ef1b150..e38b9390d 100644 --- a/pkg/domain/infra/abi/images_test.go +++ b/pkg/domain/infra/abi/images_test.go @@ -1,5 +1,22 @@ package abi +import ( + "testing" + + "github.com/containers/common/libimage" + "github.com/stretchr/testify/assert" +) + +// This is really intended to verify what happens with a +// nil pointer in layer.Created, but we'll just sanity +// check round tripping 42. +func TestToDomainHistoryLayer(t *testing.T) { + var layer libimage.ImageHistory + layer.Size = 42 + newLayer := toDomainHistoryLayer(&layer) + assert.Equal(t, layer.Size, newLayer.Size) +} + // // import ( // "context" -- cgit v1.2.3-54-g00ecf