Add some tests for Index
Including making the default :undefined, so the NIF doesn't get upset. Implementing the Access protocol would require a struct, so we may or may not want that.
This commit is contained in:
@@ -6,13 +6,15 @@ defmodule Geef.Index.Entry do
|
||||
vals = :lists.map(&{&1, [], nil}, keys)
|
||||
pairs = :lists.zip(keys, vals)
|
||||
|
||||
defstruct keys
|
||||
defaults = :lists.map(fn(_) -> :undefined end, keys)
|
||||
|
||||
defstruct :lists.zip(keys, defaults)
|
||||
|
||||
def from_record({:geef_index_entry, unquote_splicing(vals)}) do
|
||||
%Geef.Index.Entry{unquote_splicing(pairs)}
|
||||
end
|
||||
|
||||
def to_record(%Geef.Index.Entry{unquote_splicing(pairs)}) do
|
||||
def to_record(e = %Geef.Index.Entry{unquote_splicing(pairs)}) do
|
||||
{:geef_index_entry, unquote_splicing(vals)}
|
||||
end
|
||||
|
||||
@@ -60,6 +62,10 @@ defmodule Geef.Index do
|
||||
:geef_index.write(pid)
|
||||
end
|
||||
|
||||
def write_tree(pid, repo) do
|
||||
:geef_index.write_tree(pid, repo)
|
||||
end
|
||||
|
||||
@spec write!(pid()) :: :ok
|
||||
def write!(pid) do
|
||||
case write(pid) do
|
||||
|
||||
Reference in New Issue
Block a user