1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-08 10:49:25 +00:00

Fix parsing of metadata.fields when age is already a duration (#700)

* Fix parsing of metadata.fields when age is already a duration

* Fix frozen "now"

* Use ParseTimestampOrHumanReadableDuration instead
This commit is contained in:
Alejandro Ruiz
2025-07-01 18:53:51 +02:00
committed by GitHub
parent c782fea615
commit 61173104af
3 changed files with 21 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ import (
)
func TestTransformChain(t *testing.T) {
now = func() time.Time { return time.Date(1992, 9, 2, 0, 0, 0, 0, time.UTC) }()
now = func() time.Time { return time.Date(1992, 9, 2, 0, 0, 0, 0, time.UTC) }
noColumns := []rescommon.ColumnDefinition{}
tests := []struct {
name string
@@ -154,7 +154,7 @@ func TestTransformChain(t *testing.T) {
"message": "",
},
"fields": []interface{}{
fmt.Sprintf("%d", now.Add(-24*time.Hour).UnixMilli()),
fmt.Sprintf("%d", now().Add(-24*time.Hour).UnixMilli()),
},
},
"id": "test-ns/testobj",
@@ -216,7 +216,7 @@ func TestTransformChain(t *testing.T) {
"message": "",
},
"fields": []interface{}{
fmt.Sprintf("%d", now.Add(-24*time.Hour).UnixMilli()),
fmt.Sprintf("%d", now().Add(-24*time.Hour).UnixMilli()),
},
},
"id": "test-ns/testobj",