Packages
stateful_agents
0.1.0
This project provides boilerplate modules for using Agents for common persistence use-cases. I will add to this over time, as my own needs for Agent boilerplate arises.
Current section
Files
Jump to
Current section
Files
test/stateful_agents_test.exs
defmodule StatefulAgentsTest do
'''
test "greets the world" do
assert StatefulAgents.hello() == :world
refute StatefulAgents.hello() == :foobar
end
'''
defmodule MapAgentTest do
use ExUnit.Case, async: true
alias StatefulAgents.MapAgent
setup do
{:ok, pid} = MapAgent.start
{:ok, pid: pid}
end
doctest StatefulAgents.MapAgent
# Negative testing for MapAgent
test "test that setup started an agent for us to work with", context do
assert is_pid(context[:pid])
end
test "ensure that set fails appropriately when the wrong data type is passed", context do
assert_raise(ArgumentError, fn -> MapAgent.set(context[:pid], true) end)
end
end
defmodule BooleanAgentTest do
use ExUnit.Case, async: true
doctest StatefulAgents.BooleanAgent
end
end