(t *testing.T)
| 1860 | } |
| 1861 | |
| 1862 | func TestDB_HugeValue(t *testing.T) { |
| 1863 | dbPath := filepath.Join(t.TempDir(), "db") |
| 1864 | db, err := bolt.Open(dbPath, 0600, nil) |
| 1865 | require.NoError(t, err) |
| 1866 | defer func() { |
| 1867 | require.NoError(t, db.Close()) |
| 1868 | }() |
| 1869 | |
| 1870 | maxSize := 0xFFFFFFF + 1 |
| 1871 | // On 32 bit systems, the MaxAllocSize is 0xFFFFFFF (268435455, |
| 1872 | // roughly 256MB), and the test will fail for sure, so we reduce |
| 1873 | // the maxSize by half in such case. |
| 1874 | if maxSize > common.MaxAllocSize { |
| 1875 | maxSize = maxSize / 2 |
| 1876 | } |
| 1877 | data := make([]byte, maxSize) |
| 1878 | |
| 1879 | _ = db.Update(func(tx *bolt.Tx) error { |
| 1880 | b, err := tx.CreateBucketIfNotExists([]byte("data")) |
| 1881 | require.NoError(t, err) |
| 1882 | |
| 1883 | err = b.Put([]byte("key"), data) |
| 1884 | require.NoError(t, err) |
| 1885 | |
| 1886 | return nil |
| 1887 | }) |
| 1888 | } |
| 1889 | |
| 1890 | func ExampleDB_Update() { |
| 1891 | // Open the database. |
nothing calls this directly
no test coverage detected