Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions test/plausible/session/cache_store_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Plausible.Session.CacheStoreTest do
use Plausible.DataCase
use Plausible.DataCase, asyc: true
alias Plausible.Session.CacheStore

defmodule FakeBuffer do
Expand Down Expand Up @@ -123,8 +123,16 @@ defmodule Plausible.Session.CacheStoreTest do
Plausible.Session.WriteBuffer.flush()
end

defp random_user_id() do
SipHash.hash!(:crypto.strong_rand_bytes(16), Ecto.UUID.generate())
end

test "across parts" do
e = build(:event, name: "pageview")
e =
build(:event,
name: "pageview",
user_id: random_user_id()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, this is factory-provided

)

flush([%{e | pathname: "/"}])
flush([%{e | pathname: "/exit"}])
Expand All @@ -138,7 +146,11 @@ defmodule Plausible.Session.CacheStoreTest do
end

test "within parts" do
e = build(:event, name: "pageview")
e =
build(:event,
name: "pageview",
user_id: random_user_id()
)

flush([
%{e | pathname: "/"},
Expand All @@ -154,7 +166,7 @@ defmodule Plausible.Session.CacheStoreTest do
end

test "across and within parts" do
e = build(:event, name: "pageview")
e = build(:event, name: "pageview", user_id: random_user_id())

flush([
%{e | pathname: "/"},
Expand Down