add Geef.Config module for Elixir
This commit is contained in:
committed by
Carlos Martín Nieto
parent
8c39463095
commit
01254f2f90
30
test/config_test.exs
Normal file
30
test/config_test.exs
Normal file
@@ -0,0 +1,30 @@
|
||||
defmodule ConfigTest do
|
||||
use ExUnit.Case
|
||||
use Geef
|
||||
import RepoHelpers
|
||||
|
||||
|
||||
setup do
|
||||
{repo, path} = tmp_bare
|
||||
Process.link(repo)
|
||||
{:ok, config} = Repository.config(repo)
|
||||
on_exit(fn -> File.rm_rf!(path) end)
|
||||
{:ok, [config: config, path: path]}
|
||||
end
|
||||
|
||||
test "write and get a boolean", meta do
|
||||
config = meta[:config]
|
||||
var = "core.logallrefupdates"
|
||||
assert :ok = Config.set(config, var, true)
|
||||
assert {:ok, true} = Config.get_bool(config, var)
|
||||
end
|
||||
|
||||
test "write and get a string", meta do
|
||||
config = meta[:config]
|
||||
var = "user.name"
|
||||
val = "Random J. Hacker"
|
||||
assert :ok = Config.set(config, var, val)
|
||||
assert {:ok, ^val} = Config.get_string(config, var)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,7 +2,7 @@ ExUnit.start
|
||||
|
||||
defmodule RepoHelpers do
|
||||
def tmp_bare do
|
||||
{a, b, c} = :erlang.now()
|
||||
{a, b, c} = :erlang.timestamp()
|
||||
n = node()
|
||||
dir = :io_lib.format("geef-~p~p~p~p.git", [n, a, b, c])
|
||||
path = Path.join(System.tmp_dir!, dir)
|
||||
|
||||
Reference in New Issue
Block a user