satellite/metainfo: add TestingAll{Segments,Objects}

Change-Id: Ia758c119d5ebd7bbb21216a463c99c2e9afcdeb0
This commit is contained in:
Egon Elbre 2020-12-15 14:58:57 +02:00 committed by Kaloyan Raev
parent 9db28b92e7
commit 4706f01876
2 changed files with 39 additions and 0 deletions

View File

@ -208,6 +208,11 @@ type MetabaseDB interface {
// TestingAllObjectSegments gets all segments for given object. Use only for testing purposes.
TestingAllObjectSegments(ctx context.Context, objectLocation metabase.ObjectLocation) (segments []metabase.Segment, err error)
// TestingAllObjects gets all objects. Use only for testing purposes.
TestingAllObjects(ctx context.Context) (segments []metabase.Object, err error)
// TestingAllSegments gets all segments. Use only for testing purposes.
TestingAllSegments(ctx context.Context) (segments []metabase.Segment, err error)
// InternalImplementation returns *metabase.DB.
// TODO: remove.
InternalImplementation() interface{}

View File

@ -413,3 +413,37 @@ func (db *DB) TestingAllObjectSegments(ctx context.Context, objectLocation Objec
return response.Segments, nil
}
// TestingAllObjects gets all objects.
// Use only for testing purposes.
func (db *DB) TestingAllObjects(ctx context.Context) (objects []Object, err error) {
defer mon.Task()(&ctx)(&err)
rawObjects, err := db.testingGetAllObjects(ctx)
if err != nil {
return nil, Error.Wrap(err)
}
for _, o := range rawObjects {
objects = append(objects, Object(o))
}
return objects, nil
}
// TestingAllSegments gets all segments.
// Use only for testing purposes.
func (db *DB) TestingAllSegments(ctx context.Context) (segments []Segment, err error) {
defer mon.Task()(&ctx)(&err)
rawSegments, err := db.testingGetAllSegments(ctx)
if err != nil {
return nil, Error.Wrap(err)
}
for _, s := range rawSegments {
segments = append(segments, Segment(s))
}
return segments, nil
}