mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-09-19 11:03:52 +00:00
Feature/endgame play (#1)
* create endgame play section * add cache tests * normalise FENs - trim and fuill move to 1 on addition * remove svg on root and allow navbar to exist across all pages * update nav items
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
defmodule Chesstrainer.CacheTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias Chesstrainer.Cache
|
||||
|
||||
setup do
|
||||
table = :"test_#{System.unique_integer([:positive])}"
|
||||
{:ok, pid} = Cache.start_link(table)
|
||||
on_exit(fn -> if Process.alive?(pid), do: GenServer.stop(pid) end)
|
||||
{:ok, %{pid: pid, table: table}}
|
||||
end
|
||||
|
||||
describe "ChessTrainer.Cache function tests" do
|
||||
test "cache is started", %{pid: pid, table: table} do
|
||||
assert is_pid(pid)
|
||||
assert 0 = Cache.size(table)
|
||||
end
|
||||
|
||||
test "put/3", %{table: table} do
|
||||
assert :ok = Cache.put(table, "key1", "value1")
|
||||
assert {:ok, "value1"} = Cache.get(table, "key1")
|
||||
assert 1 = Cache.size(table)
|
||||
|
||||
assert :ok = Cache.put(table, "key2", "value2")
|
||||
assert {:ok, "value2"} = Cache.get(table, "key2")
|
||||
assert 2 = Cache.size(table)
|
||||
end
|
||||
|
||||
test "delete/2", %{table: table} do
|
||||
assert :ok = Cache.put(table, "key1", "value1")
|
||||
assert :ok = Cache.put(table, "key2", "value2")
|
||||
assert 2 = Cache.size(table)
|
||||
|
||||
assert :ok = Cache.delete(table, "key1")
|
||||
assert 1 = Cache.size(table)
|
||||
assert :error = Cache.get(table, "key1")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user