MCPcopy
hub / github.com/etcd-io/bbolt / TestBucket_Get_IncompatibleValue

Function TestBucket_Get_IncompatibleValue

bucket_test.go:64–83  ·  view source on GitHub ↗

Ensure that a bucket retrieved via Get() returns a nil.

(t *testing.T)

Source from the content-addressed store, hash-verified

62
63// Ensure that a bucket retrieved via Get() returns a nil.
64func TestBucket_Get_IncompatibleValue(t *testing.T) {
65 db := btesting.MustCreateDB(t)
66 if err := db.Update(func(tx *bolt.Tx) error {
67 _, err := tx.CreateBucket([]byte("widgets"))
68 if err != nil {
69 t.Fatal(err)
70 }
71
72 if _, err := tx.Bucket([]byte("widgets")).CreateBucket([]byte("foo")); err != nil {
73 t.Fatal(err)
74 }
75
76 if tx.Bucket([]byte("widgets")).Get([]byte("foo")) != nil {
77 t.Fatal("expected nil value")
78 }
79 return nil
80 }); err != nil {
81 t.Fatal(err)
82 }
83}
84
85// Ensure that a slice returned from a bucket has a capacity equal to its length.
86// This also allows slices to be appended to since it will require a realloc by Go.

Callers

nothing calls this directly

Calls 6

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
FatalMethod · 0.65
CreateBucketMethod · 0.45
BucketMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected