I am having mixed results with DETS on my tests. They will pass sometimes and others they wont. It seems like maybe the record hasn’t been written fast enough and is causing my tests to fail. (My tests are checking that a function has mutated the value inside of a DETS table.) Does that sound like it could be happening? and if so, is there a way around it? like a way to ensure the update has been written before moving on?
some of the code:
def last_hash do
{:ok, table} = last_hash_table |> :dets.open_file([type: :set])
ret = :dets.lookup(table, :last_hash) |> Keyword.get(:last_hash, "AAAA")
:dets.close(table)
ret
end
defp last_hash(str) do
{:ok, table} = last_hash_table |> :dets.open_file([type: :set])
ret = :dets.insert(table, {:last_hash, str})
:dets.close(table)
ret
end
Thanks!