mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
fix(metadb): set LastUpdated field also for indexes (#2088)
Signed-off-by: Andreea-Lupu <andreealupu1470@yahoo.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package convert_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
@@ -70,3 +71,31 @@ func TestConvertErrors(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetProtoEarlierUpdatedImage(t *testing.T) {
|
||||
Convey("GetProtoEarlierUpdatedImage with nil params", t, func() {
|
||||
// repoLastImage is nil
|
||||
lastImage := gen.RepoLastUpdatedImage{}
|
||||
|
||||
repoLastUpdatedImage := convert.GetProtoEarlierUpdatedImage(nil, &lastImage)
|
||||
So(repoLastUpdatedImage, ShouldNotBeNil)
|
||||
So(repoLastUpdatedImage.LastUpdated, ShouldBeNil)
|
||||
|
||||
// lastImage is nil
|
||||
repoLastImage := gen.RepoLastUpdatedImage{}
|
||||
|
||||
repoLastUpdatedImage = convert.GetProtoEarlierUpdatedImage(&repoLastImage, nil)
|
||||
So(repoLastUpdatedImage, ShouldNotBeNil)
|
||||
So(repoLastUpdatedImage.LastUpdated, ShouldBeNil)
|
||||
|
||||
// lastImage.LastUpdated is not nil, but repoLastImage.LastUpdated is nil
|
||||
lastUpdated := time.Time{}
|
||||
lastImage = gen.RepoLastUpdatedImage{
|
||||
LastUpdated: convert.GetProtoTime(&lastUpdated),
|
||||
}
|
||||
|
||||
repoLastUpdatedImage = convert.GetProtoEarlierUpdatedImage(&repoLastImage, &lastImage)
|
||||
So(repoLastUpdatedImage, ShouldNotBeNil)
|
||||
So(repoLastUpdatedImage.LastUpdated, ShouldNotBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user