2020-05-15 17:59:37 +03:00
|
|
|
// +build kvdb_etcd
|
|
|
|
|
2020-02-18 21:35:53 +03:00
|
|
|
package etcd
|
|
|
|
|
|
|
|
// bkey is a helper functon used in tests to create a bucket key from passed
|
|
|
|
// bucket list.
|
|
|
|
func bkey(buckets ...string) string {
|
|
|
|
var bucketKey []byte
|
|
|
|
|
2020-05-12 17:02:46 +03:00
|
|
|
rootID := makeBucketID([]byte(""))
|
|
|
|
parent := rootID[:]
|
2020-02-18 21:35:53 +03:00
|
|
|
|
|
|
|
for _, bucketName := range buckets {
|
|
|
|
bucketKey = makeBucketKey(parent, []byte(bucketName))
|
|
|
|
id := makeBucketID(bucketKey)
|
|
|
|
parent = id[:]
|
|
|
|
}
|
|
|
|
|
|
|
|
return string(bucketKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
// bval is a helper function used in tests to create a bucket value (the value
|
|
|
|
// for a bucket key) from the passed bucket list.
|
|
|
|
func bval(buckets ...string) string {
|
|
|
|
id := makeBucketID([]byte(bkey(buckets...)))
|
|
|
|
return string(id[:])
|
|
|
|
}
|
|
|
|
|
|
|
|
// vkey is a helper function used in tests to create a value key from the
|
|
|
|
// passed key and bucket list.
|
|
|
|
func vkey(key string, buckets ...string) string {
|
2020-05-12 17:02:46 +03:00
|
|
|
rootID := makeBucketID([]byte(""))
|
|
|
|
bucket := rootID[:]
|
2020-02-18 21:35:53 +03:00
|
|
|
|
|
|
|
for _, bucketName := range buckets {
|
|
|
|
bucketKey := makeBucketKey(bucket, []byte(bucketName))
|
|
|
|
id := makeBucketID(bucketKey)
|
|
|
|
bucket = id[:]
|
|
|
|
}
|
|
|
|
|
|
|
|
return string(makeValueKey(bucket, []byte(key)))
|
|
|
|
}
|