Files
dolt/datas/serialize_hints_test.go
Chris Masone 0fc183d429 Refactor new DataStore code
The initial refactor had some pretty confusing struct and method
names, so this patch renames a number of things and migrates a bunch
of code to the types/ from datas/, where it seems to be a better
logical fit.

datas.cachingValueStore          -> types.ValueStore
datas.hintedChunkStore interface -> types.BatchStore
datas.naiveHintedChunkSink       -> types.BatchStoreAdaptor
datas.httpHintedChunkStore       -> datas.httpBatchStore
datas.notAHintedChunkSink        -> datas.notABatchStore

Also, types now exports a ValidatingBatchingSink, which is used by
datas.HandleWriteValue to process incoming hints and validate incoming
Chunks before putting them into a ChunkStore.

Towards Issue #1250
2016-04-15 10:57:45 -07:00

27 lines
801 B
Go

package datas
import (
"bytes"
"testing"
"github.com/attic-labs/noms/ref"
"github.com/stretchr/testify/assert"
)
func TestHintRoundTrip(t *testing.T) {
b := &bytes.Buffer{}
input := map[ref.Ref]struct{}{
ref.Parse("sha1-0000000000000000000000000000000000000000"): struct{}{},
ref.Parse("sha1-0000000000000000000000000000000000000001"): struct{}{},
ref.Parse("sha1-0000000000000000000000000000000000000002"): struct{}{},
ref.Parse("sha1-0000000000000000000000000000000000000003"): struct{}{},
}
serializeHints(b, input)
output := deserializeHints(b)
assert.Len(t, output, len(input), "Output has different number of elements than input: %v, %v", output, input)
for h := range output {
_, present := input[h]
assert.True(t, present, "%s is in output but not in input", h)
}
}