(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestMemDB_SingleWriter_MultiReader(t *testing.T) { |
| 12 | db, err := NewMemDB(testValidSchema()) |
| 13 | if err != nil { |
| 14 | t.Fatalf("err: %v", err) |
| 15 | } |
| 16 | |
| 17 | tx1 := db.Txn(true) |
| 18 | tx2 := db.Txn(false) // Should not block! |
| 19 | tx3 := db.Txn(false) // Should not block! |
| 20 | tx4 := db.Txn(false) // Should not block! |
| 21 | |
| 22 | doneCh := make(chan struct{}) |
| 23 | go func() { |
| 24 | defer close(doneCh) |
| 25 | db.Txn(true) |
| 26 | }() |
| 27 | |
| 28 | select { |
| 29 | case <-doneCh: |
| 30 | t.Fatalf("should not allow another writer") |
| 31 | case <-time.After(10 * time.Millisecond): |
| 32 | } |
| 33 | |
| 34 | tx1.Abort() |
| 35 | tx2.Abort() |
| 36 | tx3.Abort() |
| 37 | tx4.Abort() |
| 38 | |
| 39 | select { |
| 40 | case <-doneCh: |
| 41 | case <-time.After(10 * time.Millisecond): |
| 42 | t.Fatalf("should allow another writer") |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | func TestMemDB_Snapshot(t *testing.T) { |
| 47 | db, err := NewMemDB(testValidSchema()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…