add unit test

we can avoid regressions with a simple unit test that checks that timestamp
ValCounts have the appropriate values in comparisons
This commit is contained in:
reesporte 2021-11-19 09:23:01 -06:00
parent 8f85a9e88d
commit 0adfa75188
2 changed files with 15 additions and 1 deletions

View file

@ -1157,7 +1157,6 @@ func (e *executor) executeMin(ctx context.Context, qcx *Qcx, index string, c *pq
if other.Count == 0 {
return ValCount{}, nil
}
return other, nil
}

View file

@ -21,6 +21,7 @@ import (
"reflect"
"strconv"
"testing"
"time"
"github.com/molecula/featurebase/v2/pql"
"github.com/molecula/featurebase/v2/testhook"
@ -301,6 +302,20 @@ func TestValCountComparisons(t *testing.T) {
expLarger: ValCount{FloatVal: 10.7, Count: 3},
expSmaller: ValCount{FloatVal: 10.7, Count: 3},
},
{
name: "timestampEquality",
vc: ValCount{Val: -17782800, TimestampVal: time.Unix(0, -17782800*int64(time.Second)), Count: 1},
other: ValCount{Val: -17782800, TimestampVal: time.Unix(0, -17782800*int64(time.Second)), Count: 1},
expLarger: ValCount{Val: -17782800, TimestampVal: time.Unix(0, -17782800*int64(time.Second)), Count: 2},
expSmaller: ValCount{Val: -17782800, TimestampVal: time.Unix(0, -17782800*int64(time.Second)), Count: 2},
},
{
name: "timestamp",
vc: ValCount{Val: -17782800, TimestampVal: time.Unix(0, -17782800*int64(time.Second)), Count: 1},
other: ValCount{Val: 1587399600, TimestampVal: time.Unix(0, 1587399600*int64(time.Second)), Count: 1},
expLarger: ValCount{Val: 1587399600, TimestampVal: time.Unix(0, 1587399600*int64(time.Second)), Count: 1},
expSmaller: ValCount{Val: -17782800, TimestampVal: time.Unix(0, -17782800*int64(time.Second)), Count: 1},
},
}
for i, test := range tests {