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

Function TestBucket_Get_NonExistent

bucket_test.go:25–40  ·  view source on GitHub ↗

Ensure that a bucket that gets a non-existent key returns nil.

(t *testing.T)

Source from the content-addressed store, hash-verified

23
24// Ensure that a bucket that gets a non-existent key returns nil.
25func TestBucket_Get_NonExistent(t *testing.T) {
26 db := btesting.MustCreateDB(t)
27
28 if err := db.Update(func(tx *bolt.Tx) error {
29 b, err := tx.CreateBucket([]byte("widgets"))
30 if err != nil {
31 t.Fatal(err)
32 }
33 if v := b.Get([]byte("foo")); v != nil {
34 t.Fatal("expected nil value")
35 }
36 return nil
37 }); err != nil {
38 t.Fatal(err)
39 }
40}
41
42// Ensure that a bucket can read a value that is not flushed yet.
43func TestBucket_Get_FromNode(t *testing.T) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected