While here, make the object be an elixir struct instead of delegating to the erlang code. As part of this, geef_nif:commit_tree() has been fixed to return the id, insted of the type, as we know it's going to be a tree, but not then id.
32 lines
770 B
Elixir
32 lines
770 B
Elixir
defmodule ReferenceTest do
|
|
use ExUnit.Case
|
|
use Geef
|
|
import RepoHelpers
|
|
|
|
setup do
|
|
{repo, path} = tmp_bare()
|
|
on_exit(fn -> File.rm_rf!(path) end)
|
|
{:ok, [repo: repo, path: path]}
|
|
end
|
|
|
|
test "creating and looking up", meta do
|
|
repo = meta[:repo]
|
|
{ :ok, odb } = Repository.odb(repo)
|
|
content = "I'm some content"
|
|
{:ok, id} = Odb.write(odb, content, :blob)
|
|
|
|
refname = "refs/tags/foo"
|
|
{:ok, ref} = Reference.create(repo, refname, id)
|
|
{:ok, looked_up} = Reference.lookup(repo, refname)
|
|
assert ref == looked_up
|
|
|
|
refname = "refs/tags/foo2"
|
|
{:ok, ref} = Reference.create_symbolic(repo, refname, id)
|
|
{:ok, looked_up} = Reference.lookup(repo, refname)
|
|
assert ref == looked_up
|
|
|
|
Repository.stop(repo)
|
|
end
|
|
|
|
end
|