func newFakeBlobStore(ctx context.Context) (blobStore blob.Store, err error) {
	// Create a bucket.
	bucket := gcsfake.NewFakeBucket(timeutil.RealClock(), "some_bucket")

	// And a cryptoer.
	_, crypter, err := wiring.MakeRegistryAndCrypter(ctx, "password", bucket)
	if err != nil {
		err = fmt.Errorf("MakeRegistryAndCrypter: %v", err)
		return
	}

	// And the blob store.
	blobStore, err = wiring.MakeBlobStore(bucket, crypter, util.NewStringSet())
	if err != nil {
		err = fmt.Errorf("MakeBlobStore: %v", err)
		return
	}

	return
}
示例#2
0
文件: state.go 项目: jacobsa/comeback
func buildExistingScores(
	ctx context.Context,
	bucket gcs.Bucket) (existingScores util.StringSet, err error) {
	// List into a slice.
	slice, err := listAllScores(
		ctx,
		bucket,
		wiring.BlobObjectNamePrefix)

	if err != nil {
		err = fmt.Errorf("listAllScores: %v", err)
		return
	}

	// Build a set.
	existingScores = util.NewStringSet()
	for _, score := range slice {
		existingScores.Add(score.Hex())
	}

	return
}