mirror of https://github.com/poanetwork/rox.git
test(): add basic tests
This commit is contained in:
parent
1312b2a8c8
commit
1f74e54af2
|
@ -1,8 +1,33 @@
|
|||
defmodule RoxTest do
|
||||
use ExUnit.Case
|
||||
use ExUnit.Case, async: false
|
||||
doctest Rox
|
||||
|
||||
test "the truth" do
|
||||
assert 1 + 1 == 2
|
||||
setup do
|
||||
path = Path.join(__DIR__, "test.rocksdb")
|
||||
{:ok, db} = Rox.open(path, create_if_missing: true)
|
||||
|
||||
on_exit fn ->
|
||||
Rox.close(db)
|
||||
File.rm_rf(path)
|
||||
:ok
|
||||
end
|
||||
|
||||
{:ok, %{db: db}}
|
||||
end
|
||||
|
||||
test "simple put and get", %{db: db} do
|
||||
assert :not_found = Rox.get(db, "key")
|
||||
:ok = Rox.put(db, "key", "val")
|
||||
|
||||
assert {:ok, "val"} = Rox.get(db, "key")
|
||||
end
|
||||
|
||||
test "stream_keys", %{db: db} do
|
||||
:ok = Rox.put(db, "key", "val")
|
||||
|
||||
count = Rox.stream_keys(db)
|
||||
|> Enum.count
|
||||
|
||||
assert count == 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue