Created
October 31, 2015 09:38
-
-
Save imranismail/a156fc233f01b4a69a21 to your computer and use it in GitHub Desktop.
Sharing context across tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule KeyVal.RegistryTest do | |
use ExUnit.Case, async: false | |
setup do | |
{:ok, registry} = KeyVal.Registry.start_link | |
{:ok, registry: registry} | |
end | |
test "spawns bucket", %{registry: registry} do | |
assert {:ok, _bucket} = KeyVal.Registry.create(registry, "shopping") | |
assert KeyVal.Registry.create(registry, "shopping") == :error | |
end | |
test "can lookup for a bucket", %{registry: registry} do | |
assert {:ok, bucket} = KeyVal.Registry.lookup(registry, "shopping") | |
end | |
test "can store value in spawned bucket", %{registry: registry} do | |
assert {:ok, bucket} = KeyVal.Registry.lookup(registry, "shopping") | |
KeyVal.Bucket.put(bucket, "eggs", 1) | |
assert KeyVal.Bucket.get(bucket, "eggs") == 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment