MCPcopy Create free account
hub / github.com/couchbase/moss / testSimpleStoreEx

Function testSimpleStoreEx

store_test.go:314–505  ·  view source on GitHub ↗
(t *testing.T,
	label string,
	callbacks map[string]func(string),
	storeOptions StoreOptions,
	storePersistOptions StorePersistOptions,
	collectionOptions CollectionOptions,
	expectedNextFNameSeq int64)

Source from the content-addressed store, hash-verified

312}
313
314func testSimpleStoreEx(t *testing.T,
315 label string,
316 callbacks map[string]func(string),
317 storeOptions StoreOptions,
318 storePersistOptions StorePersistOptions,
319 collectionOptions CollectionOptions,
320 expectedNextFNameSeq int64) {
321 tmpDir, _ := ioutil.TempDir("", "mossStore")
322 defer os.RemoveAll(tmpDir)
323
324 store, err := OpenStore(tmpDir, storeOptions)
325 if err != nil || store == nil {
326 t.Errorf("expected open empty store to work")
327 }
328
329 coll, _ := NewCollection(collectionOptions)
330 coll.Start()
331
332 b, _ := coll.NewBatch(0, 0)
333 b.Set([]byte("a"), []byte("A"))
334 b2, _ := b.NewChildCollectionBatch("child", BatchOptions{0, 0})
335 b2.Set([]byte("a"), []byte("A2"))
336 coll.ExecuteBatch(b, WriteOptions{})
337
338 ss, _ := coll.Snapshot()
339
340 // ------------------------------------------------------
341
342 llss, err := store.Persist(ss, storePersistOptions)
343 if err != nil || llss == nil {
344 t.Errorf("expected persist to work")
345 }
346
347 if store.nextFNameSeq != 2 {
348 t.Errorf("expected store nextFNameSeq to be 2")
349 }
350
351 cs, err := llss.ChildCollectionSnapshot("child")
352 if err != nil {
353 t.Errorf("expected store to have child collection")
354 }
355 v, err := cs.Get([]byte("a"), ReadOptions{})
356 if err != nil || string(v) != "A2" {
357 t.Errorf("expected llss child get to work, err: %v, v: %v", err, v)
358 }
359
360 v, err = llss.Get([]byte("a"), ReadOptions{})
361 if err != nil || string(v) != "A" {
362 t.Errorf("expected llss get to work, err: %v, v: %v", err, v)
363 }
364
365 iter, err := llss.StartIterator(nil, nil, IteratorOptions{})
366 if err != nil || iter == nil {
367 t.Errorf("expected llss iter to start")
368 }
369
370 iterk, iterv, err := iter.Current()
371 if err != nil || string(iterk) != "a" || string(iterv) != "A" {

Callers 2

testSimpleStoreFunction · 0.85

Calls 15

StartMethod · 0.95
NewBatchMethod · 0.95
SetMethod · 0.95
ExecuteBatchMethod · 0.95
SnapshotMethod · 0.95
OpenStoreFunction · 0.85
NewCollectionFunction · 0.85
PersistMethod · 0.65
GetMethod · 0.65
StartIteratorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…