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

Function TestBucket_Get_FromNode

bucket_test.go:43–61  ·  view source on GitHub ↗

Ensure that a bucket can read a value that is not flushed yet.

(t *testing.T)

Source from the content-addressed store, hash-verified

41
42// Ensure that a bucket can read a value that is not flushed yet.
43func TestBucket_Get_FromNode(t *testing.T) {
44 db := btesting.MustCreateDB(t)
45
46 if err := db.Update(func(tx *bolt.Tx) error {
47 b, err := tx.CreateBucket([]byte("widgets"))
48 if err != nil {
49 t.Fatal(err)
50 }
51 if err := b.Put([]byte("foo"), []byte("bar")); err != nil {
52 t.Fatal(err)
53 }
54 if v := b.Get([]byte("foo")); !bytes.Equal(v, []byte("bar")) {
55 t.Fatalf("unexpected value: %v", v)
56 }
57 return nil
58 }); err != nil {
59 t.Fatal(err)
60 }
61}
62
63// Ensure that a bucket retrieved via Get() returns a nil.
64func TestBucket_Get_IncompatibleValue(t *testing.T) {

Callers

nothing calls this directly

Calls 7

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
FatalMethod · 0.65
FatalfMethod · 0.65
CreateBucketMethod · 0.45
PutMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected