@@ -36,6 +36,7 @@ import (
3636 "github.com/containerd/containerd/content"
3737 "github.com/containerd/containerd/content/testsuite"
3838 "github.com/containerd/containerd/pkg/testutil"
39+
3940 "github.com/opencontainers/go-digest"
4041 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
4142 "gotest.tools/assert"
@@ -392,3 +393,24 @@ func setupIncompleteWrite(ctx context.Context, t *testing.T, cs content.Store, r
392393
393394 assert .NilError (t , writer .Close ())
394395}
396+
397+ func TestWriteReadEmptyFileTimestamp (t * testing.T ) {
398+ root , err := ioutil .TempDir ("" , "test-write-read-file-timestamp" )
399+ if err != nil {
400+ t .Errorf ("failed to create a tmp dir: %v" , err )
401+ }
402+ defer os .RemoveAll (root )
403+
404+ emptyFile := filepath .Join (root , "updatedat" )
405+ if err := writeTimestampFile (emptyFile , time.Time {}); err != nil {
406+ t .Errorf ("failed to write Zero Time to file: %v" , err )
407+ }
408+
409+ timestamp , err := readFileTimestamp (emptyFile )
410+ if err != nil {
411+ t .Errorf ("read empty timestamp file should success, but got error: %v" , err )
412+ }
413+ if ! timestamp .IsZero () {
414+ t .Errorf ("read empty timestamp file should return time.Time{}, but got: %v" , timestamp )
415+ }
416+ }
0 commit comments