(t *testing.T, label string, callbacks map[string]func(string), storeOptions StoreOptions, storePersistOptions StorePersistOptions, collectionOptions CollectionOptions, expectedNextFNameSeq int64)
| 312 | } |
| 313 | |
| 314 | func 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" { |
no test coverage detected
searching dependent graphs…