fix prolly field tests

This commit is contained in:
Andy Arthur
2022-05-26 15:35:33 -07:00
parent 1cd308176d
commit ec5c7e665e

View File

@@ -16,6 +16,7 @@ package index
import (
"encoding/json"
"github.com/shopspring/decimal"
"math"
"testing"
"time"
@@ -103,7 +104,7 @@ func TestRoundTripProllyFields(t *testing.T) {
{
name: "decimal",
typ: val.Type{Enc: val.DecimalEnc},
value: "0.263419374632932747932030573792",
value: mustParseDecimal("0.263419374632932747932030573792"),
},
{
name: "string",
@@ -125,11 +126,11 @@ func TestRoundTripProllyFields(t *testing.T) {
typ: val.Type{Enc: val.DateEnc},
value: dateFromTime(time.Now().UTC()),
},
//{
// name: "time",
// typ: val.Type{Enc: val.DateEnc},
// value: dateFromTime(time.Now().UTC()),
//},
{
name: "time",
typ: val.Type{Enc: val.TimeEnc},
value: int64(123456),
},
{
name: "datetime",
typ: val.Type{Enc: val.DatetimeEnc},
@@ -212,6 +213,14 @@ func mustParseJson(t *testing.T, s string) sql.JSONDocument {
return sql.JSONDocument{Val: v}
}
func mustParseDecimal(s string) decimal.Decimal {
d, err := decimal.NewFromString(s)
if err != nil {
panic(err)
}
return d
}
func dateFromTime(t time.Time) time.Time {
y, m, d := t.Year(), t.Month(), t.Day()
return time.Date(y, m, d, 0, 0, 0, 0, time.UTC)