-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests
56 lines (42 loc) · 1.63 KB
/
tests
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
50
51
52
53
54
55
56
todo_list = Todo.new()
|> Todo.add_entry(%{date: ~D[2023-12-19], title: "Dentist"})
|> Todo.add_entry(%{date: ~D[2023-12-20], title: "Shopping"})
|> Todo.add_entry(%{date: ~D[2023-12-19], title: "Movies"})
Todo.update_entry(todo_list, 1, &Map.put(&1, :title, "ajsdkasjdkas"))
Todo.delete_entry(todo_list, 1)
entries = [
%{date: ~D[2023-12-19], title: "Dentist"},
%{date: ~D[2023-12-20], title: "Shopping"},
%{date: ~D[2023-12-19], title: "Movies"}
]
todo_list = Todo.new(entries)
Enum.into(entries, Todo.new())
{:ok, todo_server} = Todo.Server.start(nil)
Todo.Server.add_entry(%{date: ~D[2023-12-19], title: "Dentist"})
Todo.Server.entries(~D[2023-12-19])
{:ok, cache} = Todo.Cache.start()
Todo.Cache.server_process(cache, "Bob's list")
Todo.Cache.server_process(cache, "Bob's list")
Todo.Cache.server_process(cache, "Alice's list")
{:ok, cache} = Todo.Cache.start()
bobs_list = Todo.Cache.server_process(cache, "Bob's list")
Todo.Server.add_entry(
bobs_list,
%{date: ~D[2023-12-19], title: "Dentist"}
)
Todo.Server.entries(bobs_list, ~D[2023-12-19])
Todo.Cache.server_process(cache, "Alice's list")
|> Todo.Server.entries(~D[2023-12-19])
Supervisor.start_link([Todo.Cache], strategy: :one_for_one)
cache_pid = Process.whereis(Todo.Cache)
Process.exit(cache_pid, :kill)
Todo.System.start_link()
Todo.Cache.server_process("Bob's list")
length(Process.list())
Process.exit(Process.whereis(Todo.Cache), :kill)
bobs_list = Todo.Cache.server_process("Bob's list")
length(Process.list())
Todo.System.start_link()
bobs_list = Todo.Cache.server_process("Bob's list")
alices_list = Todo.Cache.server_process("Alice's list")
Process.exit(bobs_list, :kill)