mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-10 00:39:44 -06:00
go/store/nbs: Improve testing for TableFileStore.Size().
This commit is contained in:
@@ -463,6 +463,10 @@ func (dcs *DoltChunkStore) Rebase(ctx context.Context) error {
|
||||
return NewRpcError(err, "Rebase", dcs.host, req)
|
||||
}
|
||||
|
||||
return dcs.refreshRepoMetadata(ctx)
|
||||
}
|
||||
|
||||
func (dcs *DoltChunkStore) refreshRepoMetadata(ctx context.Context) error {
|
||||
mdReq := &remotesapi.GetRepoMetadataRequest{
|
||||
RepoId: &remotesapi.RepoId{
|
||||
Org: dcs.org,
|
||||
@@ -478,7 +482,6 @@ func (dcs *DoltChunkStore) Rebase(ctx context.Context) error {
|
||||
return NewRpcError(err, "GetRepoMetadata", dcs.host, mdReq)
|
||||
}
|
||||
dcs.metadata = metadata
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -521,28 +524,11 @@ func (dcs *DoltChunkStore) Commit(ctx context.Context, current, last hash.Hash)
|
||||
},
|
||||
}
|
||||
resp, err := dcs.csClient.Commit(ctx, req)
|
||||
|
||||
if err != nil {
|
||||
return false, NewRpcError(err, "Commit", dcs.host, req)
|
||||
}
|
||||
|
||||
mdReq := &remotesapi.GetRepoMetadataRequest{
|
||||
RepoId: &remotesapi.RepoId{
|
||||
Org: dcs.org,
|
||||
RepoName: dcs.repoName,
|
||||
},
|
||||
ClientRepoFormat: &remotesapi.ClientRepoFormat{
|
||||
NbfVersion: dcs.nbf.VersionString(),
|
||||
NbsVersion: nbs.StorageVersion,
|
||||
},
|
||||
}
|
||||
metadata, err := dcs.csClient.GetRepoMetadata(ctx, mdReq)
|
||||
if err != nil {
|
||||
return false, NewRpcError(err, "GetRepoMetadata", dcs.host, mdReq)
|
||||
}
|
||||
dcs.metadata = metadata
|
||||
|
||||
return resp.Success, nil
|
||||
return resp.Success, dcs.refreshRepoMetadata(ctx)
|
||||
}
|
||||
|
||||
// Stats may return some kind of struct that reports statistics about the
|
||||
|
||||
@@ -409,7 +409,7 @@ func (ttfWr *TestTableFileWriter) Close(ctx context.Context) error {
|
||||
|
||||
type TestTableFileStore struct {
|
||||
root hash.Hash
|
||||
tableFiles map[string]nbs.TableFile
|
||||
tableFiles map[string]*TestTableFile
|
||||
}
|
||||
|
||||
func (ttfs *TestTableFileStore) Sources(ctx context.Context) (hash.Hash, []nbs.TableFile, error) {
|
||||
@@ -422,7 +422,11 @@ func (ttfs *TestTableFileStore) Sources(ctx context.Context) (hash.Hash, []nbs.T
|
||||
}
|
||||
|
||||
func (ttfs *TestTableFileStore) Size(ctx context.Context) (uint64, error) {
|
||||
return 0, nil
|
||||
sz := uint64(0)
|
||||
for _, tblFile := range ttfs.tableFiles {
|
||||
sz += uint64(len(tblFile.data))
|
||||
}
|
||||
return sz, nil
|
||||
}
|
||||
|
||||
func (ttfs *TestTableFileStore) WriteTableFile(ctx context.Context, fileId string, numChunks int, rd io.Reader, contentLength uint64, contentHash []byte) error {
|
||||
@@ -452,7 +456,7 @@ func TestClone(t *testing.T) {
|
||||
hashBytes := [hash.ByteLen]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13}
|
||||
src := &TestTableFileStore{
|
||||
root: hash.Of(hashBytes[:]),
|
||||
tableFiles: map[string]nbs.TableFile{
|
||||
tableFiles: map[string]*TestTableFile{
|
||||
"file1": &TestTableFile{
|
||||
fileID: "file1",
|
||||
numChunks: 1,
|
||||
@@ -483,7 +487,7 @@ func TestClone(t *testing.T) {
|
||||
|
||||
dest := &TestTableFileStore{
|
||||
root: hash.Hash{},
|
||||
tableFiles: map[string]nbs.TableFile{},
|
||||
tableFiles: map[string]*TestTableFile{},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -76,4 +76,8 @@ func TestNBSAsTableFileStore(t *testing.T) {
|
||||
|
||||
assert.Equal(t, expected, data)
|
||||
}
|
||||
|
||||
size, err := st.Size(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Greater(t, size, uint64(0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user