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

Function TestBucket_Put_Large

bucket_test.go:173–204  ·  view source on GitHub ↗

Ensure that a bucket can write a bunch of large values.

(t *testing.T)

Source from the content-addressed store, hash-verified

171
172// Ensure that a bucket can write a bunch of large values.
173func TestBucket_Put_Large(t *testing.T) {
174 db := btesting.MustCreateDB(t)
175
176 count, factor := 100, 200
177 if err := db.Update(func(tx *bolt.Tx) error {
178 b, err := tx.CreateBucket([]byte("widgets"))
179 if err != nil {
180 t.Fatal(err)
181 }
182 for i := 1; i < count; i++ {
183 if err := b.Put([]byte(strings.Repeat("0", i*factor)), []byte(strings.Repeat("X", (count-i)*factor))); err != nil {
184 t.Fatal(err)
185 }
186 }
187 return nil
188 }); err != nil {
189 t.Fatal(err)
190 }
191
192 if err := db.View(func(tx *bolt.Tx) error {
193 b := tx.Bucket([]byte("widgets"))
194 for i := 1; i < count; i++ {
195 value := b.Get([]byte(strings.Repeat("0", i*factor)))
196 if !bytes.Equal(value, []byte(strings.Repeat("X", (count-i)*factor))) {
197 t.Fatalf("unexpected value: %v", value)
198 }
199 }
200 return nil
201 }); err != nil {
202 t.Fatal(err)
203 }
204}
205
206// Ensure that a database can perform multiple large appends safely.
207func TestDB_Put_VeryLarge(t *testing.T) {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected