func BucketId(bucketId typing.BucketId) btesting.Writer { return func(config *btesting.Configuration) interface{} { if config.Bool("BucketIdBinary") { return []byte(bucketId) } else { return bucketId.ToBase32String() } } }
func SetPutReceiver(t btesting.T, bucketId typing.BucketId, receivers ...typing.BucketId) { // Now configure bucket "one" to forward the puts to bucket "two" putReceivers := make([][]byte, len(receivers)) for index, receiver := range receivers { putReceivers[index] = []byte(receiver) } newPutReceiversEncoded, err := encoding.Cbor().Encode(putReceivers) if err != nil { t.Errorf("%v", err) return } Put(t, bucketId.ToMetadataBucketId(), typing.KeyFromStringPanic("system.put_receivers"), typing.ValueFromInterfacePanic([][]byte{newPutReceiversEncoded})) }
// 1. Creates a bucket (storage) // 2. Sees what metadata can be found for hat bucket. func testScanMetadata(t btesting.T) { // The haser bucket is the simplest one, it currently only has one single metadata: // 'const.system.type_id' // First create a bucket var bucketId typing.BucketId operations.CreateBucket(t, typing.TypeId_Store, &bucketId) if t.Failed() { return } var keyAsBinary []byte t.Request(btesting.Request{ Input: btesting.Object{ "Operation": "Scan", "Data": btesting.Object{ "BucketId": fmt.Sprintf(":meta-id:%v", bucketId.ToBase32String()), "FromKey": "", "Limit": 1, }, }, Expecting: btesting.Object{ "Code": eval.RetcodeOk(), "Data": btesting.Object{ "HasMore": false, "Results": btesting.Array{ btesting.Object{ "Key": btesting.Array{eval.IsAnyBinaryB32(&keyAsBinary)}, }, }, }, }, }) if t.Failed() { return } keyAsString := string(keyAsBinary) if keyAsString != "const.system.type_id" { t.Errorf("Expecting to have the metadata const.system.type_id but have %v", keyAsString) return } }