-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid returning results from other tables on AsyncStore.next/prev (
#806)
- Loading branch information
Showing
2 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule AeMdw.Db.AsyncStoreTest do | ||
use ExUnit.Case | ||
|
||
alias AeMdw.Db.AsyncStore | ||
alias AeMdw.Db.Store | ||
|
||
describe "next/2" do | ||
test "it returns the next value" do | ||
store = AsyncStore.instance() | ||
|
||
store = | ||
store | ||
|> Store.put(:table, {:record, :key1, :val1}) | ||
|> Store.put(:table, {:record, :key2, :val2}) | ||
|
||
assert {:ok, :key1} = Store.next(store, :table, :key0) | ||
assert {:ok, :key2} = Store.next(store, :table, :key1) | ||
assert :none = Store.next(store, :table, :key2) | ||
end | ||
|
||
test "when other tables present, it doesn't return values from them" do | ||
store = AsyncStore.instance() | ||
|
||
store = | ||
store | ||
|> Store.put(:table1, {:record, :key1, :val1}) | ||
|> Store.put(:table1, {:record, :key2, :val2}) | ||
|> Store.put(:table2, {:record, :key3, :val3}) | ||
|
||
assert :none = Store.next(store, :table1, :key2) | ||
end | ||
end | ||
end |