Skip to content

Commit

Permalink
go test updates to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 committed Jan 7, 2025
1 parent a5ab0f1 commit 16be518
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions go/libraries/doltcore/remotestorage/map_chunk_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/dolthub/dolt/go/store/nbs"
)

func genRandomChunks(rng *rand.Rand, n int) (hash.HashSet, []nbs.CompressedChunk) {
chks := make([]nbs.CompressedChunk, n)
func genRandomChunks(rng *rand.Rand, n int) (hash.HashSet, []nbs.ToChunker) {
chks := make([]nbs.ToChunker, n)
hashes := make(hash.HashSet)
for i := 0; i < n; i++ {
size := int(rng.Int31n(99) + 1)
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestMapChunkCache(t *testing.T) {

toFlush = mapChunkCache.GetAndClearChunksToFlush()

expected := map[hash.Hash]nbs.CompressedChunk{moreChks[0].Hash(): moreChks[0]}
expected := map[hash.Hash]nbs.ToChunker{moreChks[0].Hash(): moreChks[0]}
eq := reflect.DeepEqual(toFlush, expected)
assert.True(t, eq, "Missing or unexpected chunks to flush (seed %d)", seed)
}
23 changes: 15 additions & 8 deletions go/store/datas/pull/pull_chunk_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ func TestPullChunkFetcher(t *testing.T) {
defer wg.Done()
cmp, err := f.Recv(context.Background())
assert.NoError(t, err)
assert.Equal(t, cmp.H, gm.C.H)
assert.Equal(t, cmp.FullCompressedChunk, gm.C.FullCompressedChunk)
assert.Equal(t, cmp.Hash(), gm.C.H)

cc, ok := cmp.(nbs.CompressedChunk)
assert.True(t, ok)

assert.Equal(t, cc.FullCompressedChunk, gm.C.FullCompressedChunk)
_, err = f.Recv(context.Background())
assert.ErrorIs(t, err, io.EOF)
assert.NoError(t, f.Close())
Expand All @@ -92,8 +96,11 @@ func TestPullChunkFetcher(t *testing.T) {
defer wg.Done()
cmp, err := f.Recv(context.Background())
assert.NoError(t, err)
assert.Equal(t, cmp.H, h)
assert.Nil(t, cmp.FullCompressedChunk)
assert.Equal(t, cmp.Hash(), h)

cc, ok := cmp.(nbs.CompressedChunk)
assert.True(t, ok)
assert.Nil(t, cc.FullCompressedChunk)
_, err = f.Recv(context.Background())
assert.ErrorIs(t, err, io.EOF)
assert.NoError(t, f.Close())
Expand Down Expand Up @@ -136,15 +143,15 @@ func TestPullChunkFetcher(t *testing.T) {
type emptyGetManyer struct {
}

func (emptyGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.CompressedChunk)) error {
func (emptyGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.ToChunker)) error {
return nil
}

type deliveringGetManyer struct {
C nbs.CompressedChunk
}

func (d deliveringGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.CompressedChunk)) error {
func (d deliveringGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.ToChunker)) error {
for _ = range hashes {
found(ctx, d.C)
}
Expand All @@ -155,7 +162,7 @@ type blockingGetManyer struct {
block chan struct{}
}

func (b blockingGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.CompressedChunk)) error {
func (b blockingGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.ToChunker)) error {
<-b.block
return nil
}
Expand All @@ -165,6 +172,6 @@ type errorGetManyer struct {

var getManyerErr = fmt.Errorf("always return an error")

func (errorGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.CompressedChunk)) error {
func (errorGetManyer) GetManyCompressed(ctx context.Context, hashes hash.HashSet, found func(context.Context, nbs.ToChunker)) error {
return getManyerErr
}
2 changes: 1 addition & 1 deletion go/store/nbs/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ func (tcs *testChunkSource) getMany(ctx context.Context, eg *errgroup.Group, req
panic("never used")
}

func (tcs *testChunkSource) getManyCompressed(ctx context.Context, eg *errgroup.Group, reqs []getRecord, found func(context.Context, CompressedChunk), stats *Stats) (bool, error) {
func (tcs *testChunkSource) getManyCompressed(ctx context.Context, eg *errgroup.Group, reqs []getRecord, found func(context.Context, ToChunker), stats *Stats) (bool, error) {
panic("never used")
}

Expand Down
4 changes: 2 additions & 2 deletions go/store/nbs/cmp_chunk_table_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func TestCmpChunkTableWriter(t *testing.T) {
}

reqs := toGetRecords(hashes)
found := make([]CompressedChunk, 0)
found := make([]ToChunker, 0)

eg, egCtx := errgroup.WithContext(ctx)
_, err = tr.getManyCompressed(egCtx, eg, reqs, func(ctx context.Context, c CompressedChunk) { found = append(found, c) }, &Stats{})
_, err = tr.getManyCompressed(egCtx, eg, reqs, func(ctx context.Context, c ToChunker) { found = append(found, c) }, &Stats{})
require.NoError(t, err)
require.NoError(t, eg.Wait())

Expand Down
2 changes: 1 addition & 1 deletion go/store/nbs/mem_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (crg chunkReaderGroup) getMany(ctx context.Context, eg *errgroup.Group, req
return true, nil
}

func (crg chunkReaderGroup) getManyCompressed(ctx context.Context, eg *errgroup.Group, reqs []getRecord, found func(context.Context, CompressedChunk), stats *Stats) (bool, error) {
func (crg chunkReaderGroup) getManyCompressed(ctx context.Context, eg *errgroup.Group, reqs []getRecord, found func(context.Context, ToChunker), stats *Stats) (bool, error) {
for _, haver := range crg {
remaining, err := haver.getManyCompressed(ctx, eg, reqs, found, stats)
if err != nil {
Expand Down

0 comments on commit 16be518

Please sign in to comment.