✨ Use ParseDate in Entry
This commit is contained in:
parent
96c3b2ff30
commit
c1b1ceb283
2 changed files with 13 additions and 8 deletions
|
|
@ -280,7 +280,7 @@ func TestEntryJsonUnmarshal(t *testing.T) {
|
|||
},
|
||||
{
|
||||
"date-field",
|
||||
`{"title":"A Title","date":"` + whens + `","posted":"` + when.Add(-time.Hour).Format(time.RFC3339) + `"}`,
|
||||
`{"title":"A Title","date":"` + whens + `","posted":"` + when.Add(-time.Hour).In(time.UTC).Format(time.RFC3339) + `"}`,
|
||||
"A Title",
|
||||
when,
|
||||
[]Meta{{"posted", when.Add(-time.Hour)}},
|
||||
|
|
@ -324,6 +324,7 @@ func getEntryJsonUnmarshalTestRunner(in, title string, date time.Time, fields []
|
|||
assert.Len(t, e.Fields, len(fields))
|
||||
for _, f := range fields {
|
||||
got := false
|
||||
fTime, isTime := f.Value.(time.Time)
|
||||
for _, m := range e.Fields {
|
||||
var mVal any = m.Value
|
||||
var fVal any = f.Value
|
||||
|
|
@ -337,6 +338,13 @@ func getEntryJsonUnmarshalTestRunner(in, title string, date time.Time, fields []
|
|||
got = true
|
||||
break
|
||||
}
|
||||
if isTime && m.Key == f.Key {
|
||||
mTime, _ := mVal.(time.Time)
|
||||
if assert.WithinRange(t, mTime, fTime.Add(-2*time.Second), fTime.Add(2*time.Second)) {
|
||||
got = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.Truef(t, got, "Couldn't find field %+v. We have %+v", f, e.Fields)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue