forked from quantum-elixir/quantum-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_registry_test.exs
49 lines (34 loc) · 1.19 KB
/
task_registry_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
defmodule Quantum.TaskRegistryTest do
@moduledoc false
use ExUnit.Case, async: true
alias Quantum.TaskRegistry
alias Quantum.TaskRegistry.StartOpts
doctest TaskRegistry,
except: [mark_running: 3, mark_finished: 3]
setup do
{:ok, _registry} = start_supervised({TaskRegistry, %StartOpts{name: __MODULE__}})
{:ok, %{registry: __MODULE__}}
end
describe "running" do
test "not running => running", %{registry: registry} do
task = make_ref()
assert :marked_running = TaskRegistry.mark_running(registry, task, self())
end
test "running => already running", %{registry: registry} do
task = make_ref()
TaskRegistry.mark_running(registry, task, self())
assert :already_running = TaskRegistry.mark_running(registry, task, self())
end
end
describe "finished" do
test "finish existing", %{registry: registry} do
task = make_ref()
TaskRegistry.mark_running(registry, task, self())
assert :ok = TaskRegistry.mark_finished(registry, task, self())
end
test "finish not existing", %{registry: registry} do
task = make_ref()
assert :ok = TaskRegistry.mark_finished(registry, task, self())
end
end
end