1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-02-03 13:11:45 +02:00
ferret/pkg/runtime/values/date_time_test.go
Tim Voronov 2baac62d1e
Bugfix/#559 html escaping (#573)
Added jettison for json encoding
2020-11-23 20:12:04 -05:00

42 lines
814 B
Go

package values_test
import (
"encoding/json"
"github.com/MontFerret/ferret/pkg/runtime/values"
. "github.com/smartystreets/goconvey/convey"
"testing"
"time"
)
func TestDateTime(t *testing.T) {
Convey(".Hash", t, func() {
Convey("It should calculate hash", func() {
d := values.NewCurrentDateTime()
h := d.Hash()
So(h, ShouldBeGreaterThan, 0)
})
Convey("Hash sum should be consistent", func() {
d := values.NewCurrentDateTime()
So(d.Hash(), ShouldEqual, d.Hash())
})
})
Convey(".MarshalJSON", t, func() {
Convey("It should correctly serialize value", func() {
value := time.Now()
json1, err := json.Marshal(value)
So(err, ShouldBeNil)
json2, err := values.NewDateTime(value).MarshalJSON()
So(err, ShouldBeNil)
So(json1, ShouldResemble, json2)
})
})
}