remote events: convert TimeNano properly

e.TimeNano contains nanoseconds since epoch, not just the nanoseconds
after e.Time.

time.Unix supports nanoseconds > 999999999 and converts them to seconds,
so just passing e.TimeNano is enough.

Signed-off-by: Leah Neukirchen <leah@vuxu.org>
This commit is contained in:
Leah Neukirchen
2021-12-17 14:56:32 +01:00
parent 8365d49a05
commit 5aedcb3643
2 changed files with 3 additions and 1 deletions

View File

@ -42,7 +42,7 @@ func ConvertToLibpodEvent(e Event) *libpodEvents.Event {
Image: image,
Name: name,
Status: status,
Time: time.Unix(e.Time, e.TimeNano),
Time: time.Unix(0, e.TimeNano),
Type: t,
Details: libpodEvents.Details{
Attributes: details,

View File

@ -62,6 +62,8 @@ var _ = Describe("Podman events", func() {
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1), "Number of events")
date := time.Now().Format("2006-01-02")
Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(date)), "event log has correct timestamp")
})
It("podman events with an event filter and container=cid", func() {