MCPcopy
hub / github.com/dgraph-io/badger / TestManifestBasic

Function TestManifestBasic

manifest_test.go:37–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35)
36
37func TestManifestBasic(t *testing.T) {
38 dir, err := ioutil.TempDir("", "badger-test")
39 require.NoError(t, err)
40 defer removeDir(dir)
41
42 opt := getTestOptions(dir)
43 {
44 kv, err := Open(opt)
45 require.NoError(t, err)
46 n := 5000
47 for i := 0; i < n; i++ {
48 if (i % 10000) == 0 {
49 fmt.Printf("Putting i=%d\n", i)
50 }
51 k := []byte(fmt.Sprintf("%16x", rand.Int63()))
52 txnSet(t, kv, k, k, 0x00)
53 }
54 txnSet(t, kv, []byte("testkey"), []byte("testval"), 0x05)
55 kv.validate()
56 require.NoError(t, kv.Close())
57 }
58
59 kv, err := Open(opt)
60 require.NoError(t, err)
61
62 require.NoError(t, kv.View(func(txn *Txn) error {
63 item, err := txn.Get([]byte("testkey"))
64 require.NoError(t, err)
65 require.EqualValues(t, "testval", string(getItemValue(t, item)))
66 require.EqualValues(t, byte(0x05), item.UserMeta())
67 return nil
68 }))
69 require.NoError(t, kv.Close())
70}
71
72func helpTestManifestFileCorruption(t *testing.T, off int64, errorContent string) {
73 dir, err := ioutil.TempDir("", "badger-test")

Callers

nothing calls this directly

Calls 11

removeDirFunction · 0.85
getTestOptionsFunction · 0.85
OpenFunction · 0.85
txnSetFunction · 0.85
getItemValueFunction · 0.85
PrintfMethod · 0.80
ViewMethod · 0.80
UserMetaMethod · 0.80
CloseMethod · 0.65
validateMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…