(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func TestUpdateAndView(t *testing.T) { |
| 148 | runBadgerTest(t, nil, func(t *testing.T, db *DB) { |
| 149 | err := db.Update(func(txn *Txn) error { |
| 150 | for i := 0; i < 10; i++ { |
| 151 | entry := NewEntry([]byte(fmt.Sprintf("key%d", i)), []byte(fmt.Sprintf("val%d", i))) |
| 152 | if err := txn.SetEntry(entry); err != nil { |
| 153 | return err |
| 154 | } |
| 155 | } |
| 156 | return nil |
| 157 | }) |
| 158 | require.NoError(t, err) |
| 159 | |
| 160 | err = db.View(func(txn *Txn) error { |
| 161 | for i := 0; i < 10; i++ { |
| 162 | item, err := txn.Get([]byte(fmt.Sprintf("key%d", i))) |
| 163 | if err != nil { |
| 164 | return err |
| 165 | } |
| 166 | |
| 167 | expected := []byte(fmt.Sprintf("val%d", i)) |
| 168 | if err := item.Value(func(val []byte) error { |
| 169 | require.Equal(t, expected, val, |
| 170 | "Invalid value for key %q. expected: %q, actual: %q", |
| 171 | item.Key(), expected, val) |
| 172 | return nil |
| 173 | }); err != nil { |
| 174 | return err |
| 175 | } |
| 176 | } |
| 177 | return nil |
| 178 | }) |
| 179 | require.NoError(t, err) |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | func TestConcurrentWrite(t *testing.T) { |
| 184 | runBadgerTest(t, nil, func(t *testing.T, db *DB) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…