X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/66c19e11db2626bd82eb755ea6552ce5caec69af..322d784513c37abc8fa1d1c05dd5f41019868735:/services/datamanager/collection/testing.go diff --git a/services/datamanager/collection/testing.go b/services/datamanager/collection/testing.go index f3c1f47664..2238433722 100644 --- a/services/datamanager/collection/testing.go +++ b/services/datamanager/collection/testing.go @@ -7,6 +7,7 @@ import ( "git.curoverse.com/arvados.git/sdk/go/blockdigest" ) +// TestCollectionSpec with test blocks and desired replication level type TestCollectionSpec struct { // The desired replication level ReplicationLevel int @@ -15,23 +16,23 @@ type TestCollectionSpec struct { Blocks []int } -// Creates a ReadCollections object for testing based on the give -// specs. Only the ReadAllCollections and UuidToCollection fields are -// populated. To populate other fields call rc.Summarize(). +// MakeTestReadCollections creates a ReadCollections object for testing +// based on the give specs. Only the ReadAllCollections and UUIDToCollection +// fields are populated. To populate other fields call rc.Summarize(). func MakeTestReadCollections(specs []TestCollectionSpec) (rc ReadCollections) { rc = ReadCollections{ ReadAllCollections: true, - UuidToCollection: map[string]Collection{}, + UUIDToCollection: map[string]Collection{}, } for i, spec := range specs { c := Collection{ - Uuid: fmt.Sprintf("col%d", i), - OwnerUuid: fmt.Sprintf("owner%d", i), + UUID: fmt.Sprintf("col%d", i), + OwnerUUID: fmt.Sprintf("owner%d", i), ReplicationLevel: spec.ReplicationLevel, BlockDigestToSize: map[blockdigest.BlockDigest]int{}, } - rc.UuidToCollection[c.Uuid] = c + rc.UUIDToCollection[c.UUID] = c for _, j := range spec.Blocks { c.BlockDigestToSize[blockdigest.MakeTestBlockDigest(j)] = j } @@ -45,16 +46,16 @@ func MakeTestReadCollections(specs []TestCollectionSpec) (rc ReadCollections) { return } -// Returns a slice giving the collection index of each collection that -// was passed in to MakeTestReadCollections. rc.Summarize() must be -// called before this method, since Summarize() assigns an index to -// each collection. +// CollectionIndicesForTesting returns a slice giving the collection +// index of each collection that was passed in to MakeTestReadCollections. +// rc.Summarize() must be called before this method, since Summarize() +// assigns an index to each collection. func (rc ReadCollections) CollectionIndicesForTesting() (indices []int) { // TODO(misha): Assert that rc.Summarize() has been called. - numCollections := len(rc.CollectionIndexToUuid) + numCollections := len(rc.CollectionIndexToUUID) indices = make([]int, numCollections) for i := 0; i < numCollections; i++ { - indices[i] = rc.CollectionUuidToIndex[fmt.Sprintf("col%d", i)] + indices[i] = rc.CollectionUUIDToIndex[fmt.Sprintf("col%d", i)] } return }