Leon4gr45 commited on
Commit
cfdf2f2
·
verified ·
1 Parent(s): f4da623

Delete test/plausible/session/salts_test.exs with huggingface_hub

Browse files
test/plausible/session/salts_test.exs DELETED
@@ -1,67 +0,0 @@
1
- defmodule Plausible.Session.SaltsTest do
2
- use Plausible.DataCase, async: false
3
-
4
- alias Plausible.Session.Salts
5
- import Ecto.Query
6
-
7
- test "agent starts and responds with current salt" do
8
- {:ok, _} = Salts.start_link(name: __MODULE__)
9
- %{current: current, previous: nil} = Salts.fetch(__MODULE__)
10
- assert is_binary(current)
11
- end
12
-
13
- test "agent starts and responds with current and previous salt after rotation" do
14
- {:ok, _} = Salts.start_link(name: __MODULE__)
15
- %{current: first, previous: nil} = Salts.fetch(__MODULE__)
16
- :ok = Salts.rotate(__MODULE__)
17
-
18
- %{current: current, previous: ^first} = Salts.fetch(__MODULE__)
19
- assert is_binary(current)
20
- end
21
-
22
- test "old salts can be cleaned" do
23
- t1 = ~U[2025-06-10 15:29:40Z]
24
-
25
- {:ok, _} = Salts.start_link(name: __MODULE__, now: t1)
26
-
27
- t2 = ~U[2025-06-11 15:29:40Z]
28
-
29
- :ok = Salts.rotate(__MODULE__, t2)
30
-
31
- %{current: old_current, previous: _old_previous} =
32
- Salts.fetch(__MODULE__)
33
-
34
- q = from(s in "salts")
35
- count = Repo.aggregate(q, :count)
36
- assert count == 2
37
-
38
- t3 = ~U[2025-06-13 15:34:40Z]
39
-
40
- :ok = Salts.rotate(__MODULE__, t3)
41
-
42
- %{current: _current, previous: ^old_current} =
43
- Salts.fetch(__MODULE__)
44
-
45
- q = from(s in "salts")
46
- count = Repo.aggregate(q, :count)
47
- assert count == 2
48
- end
49
-
50
- test "salts refresh when another node rotates them" do
51
- t1 = ~U[2024-06-10 15:29:40Z]
52
- {:ok, _} = Salts.start_link(name: :node_1, now: t1)
53
- {:ok, _} = Salts.start_link(name: :node_2, now: t1)
54
-
55
- t2 = ~U[2024-06-11 15:29:40Z]
56
-
57
- :ok = Salts.rotate(:node_2, t2)
58
-
59
- assert Salts.fetch(:node_1) != Salts.fetch(:node_2)
60
-
61
- send(:node_1, {:refresh, t2})
62
-
63
- assert eventually(fn ->
64
- {Salts.fetch(:node_1) == Salts.fetch(:node_2), :ok}
65
- end)
66
- end
67
- end