Update encoding test to work with new interface.

pull/4317/merge
Paul Dix 2015-09-17 15:46:37 -04:00
parent 318bc7281d
commit 95f9e1619e
1 changed files with 15 additions and 16 deletions

View File

@ -2,31 +2,30 @@ package pd1_test
import (
// "math/rand"
// "reflect"
"fmt"
"reflect"
"testing"
"time"
// "github.com/influxdb/influxdb/tsdb/engine/pd1"
"github.com/influxdb/influxdb/tsdb/engine/pd1"
)
func TestEncoding_FloatBlock(t *testing.T) {
// valueCount := 100
// times := getTimes(valueCount, 60, time.Second)
// values := make([]Value, len(times))
// for i, t := range times {
// values[i] = pd1.NewValue(t, rand.Float64())
// }
valueCount := 1000
times := getTimes(valueCount, 60, time.Second)
values := make(pd1.Values, len(times))
for i, t := range times {
values[i] = pd1.NewValue(t, float64(i))
}
// b := pd1.EncodeFloatBlock(nil, values)
b := values.Encode(nil)
fmt.Println("**** ", len(b))
// decodedValues, err := pd1.DecodeFloatBlock(b)
// if err != nil {
// t.Fatalf("error decoding: %s", err.Error)
// }
decodedValues := values.DecodeSameTypeBlock(b)
// if !reflect.DeepEqual(decodedValues, values) {
// t.Fatalf("unexpected results:\n\tgot: %v\n\texp: %v\n", decodedValues, values)
// }
if !reflect.DeepEqual(decodedValues, values) {
t.Fatalf("unexpected results:\n\tgot: %v\n\texp: %v\n", decodedValues, values)
}
}
func getTimes(n, step int, precision time.Duration) []time.Time {