mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
add some tests for the encoding/decoding of DistinctTimestamp
This commit is contained in:
parent
af3c5809e2
commit
060c73fb2f
1 changed files with 22 additions and 1 deletions
|
|
@ -19,8 +19,9 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/molecula/featurebase/v2"
|
||||
pilosa "github.com/molecula/featurebase/v2"
|
||||
"github.com/molecula/featurebase/v2/ingest"
|
||||
"github.com/molecula/featurebase/v2/pb"
|
||||
)
|
||||
|
||||
func testOneRoundTrip(t *testing.T, s pilosa.Serializer, obj pilosa.Message, expectedMarshalErr error, expectedUnmarshalErr error, expectedMismatchErr error) {
|
||||
|
|
@ -147,3 +148,23 @@ func TestIngestRoundTrip(t *testing.T) {
|
|||
testOneRoundTrip(t, DefaultSerializer, tc.req, nil, nil, tc.err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEncodeDecodeDistinctTimestamp(t *testing.T) {
|
||||
s := Serializer{}
|
||||
pbTime := pb.DistinctTimestamp{
|
||||
Values: []string{"this", "is", "fake", "timestamp", "values"},
|
||||
Name: "pbtime",
|
||||
}
|
||||
piloTime := pilosa.DistinctTimestamp{
|
||||
Values: []string{"this", "is", "fake", "timestamp", "values"},
|
||||
Name: "pbtime",
|
||||
}
|
||||
decoded := s.decodeDistinctTimestamp(&pbTime)
|
||||
if !reflect.DeepEqual(decoded, piloTime) {
|
||||
t.Errorf("failed to decode DistinctTimestamp. expected %v got %v", piloTime, decoded)
|
||||
}
|
||||
encoded := s.encodeDistinctTimestamp(piloTime)
|
||||
if !reflect.DeepEqual(encoded, &pbTime) {
|
||||
t.Errorf("failed to encode DistinctTimestamp. expected %v got %v", &pbTime, encoded)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue