test(): add basic tests

This commit is contained in:
Ryan Schmukler 2016-08-16 16:37:33 -07:00
parent 1312b2a8c8
commit 1f74e54af2
1 changed files with 28 additions and 3 deletions

View File

@ -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