Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.
Open
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions lib/firebase_pushid.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ defmodule FirebasePushid do
[3, 0]
"""
def increment_list(list) when is_list(list), do: Bump.call(list)
def increment_list(data) when is_pid(data) do
new_list = Cache.random_nums(data)
|> Bump.call()

def increment_list(data) when is_pid(data) or data == Cache do
new_list =
Cache.random_nums(data)
|> Bump.call()

Cache.set_random_nums(data, new_list)
end

Expand Down
6 changes: 5 additions & 1 deletion test/firebase_pushid_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule FirebasePushidTest do
import FirebasePushid

test 'generate' do
assert generate
assert generate()
end

test "new_id" do
Expand All @@ -21,4 +21,8 @@ defmodule FirebasePushidTest do
another_id = next_id(data, 1510666856950)
assert String.slice(another_id, 0..7) != "-Kyukibf"
end

test "Multiple calls with FirebasePushid.Cache" do
for _ <- 1..100, do: generate()
end
end