Skip to content
Snippets Groups Projects
Commit 0c263250 authored by ROUSSET Noemie's avatar ROUSSET Noemie
Browse files

issue BR_G73 - Identity UserID unicity code + tests

parent 1dcc8e83
No related branches found
No related tags found
No related merge requests found
......@@ -371,6 +371,12 @@ defmodule Index.Augmentation do
[{key, entry}] = :ets.lookup(local_iindex, key)
:ets.insert(local_iindex, {key, Map.merge(entry, %{isBeingKicked: !entry.member})})
end
## BR_G73
def identityUserIdUnicity(local_iindex, key) do
[{_key, entry}] = :ets.lookup(local_iindex, key)
entry.uidUnique == true
end
end
defmodule MIndex do
......
defmodule IdentityUserIdUnicityTest do
use ExUnit.Case
doctest Index.Augmentation.IIndex
setup_all do
local_iindex_a = :ets.new(:local_iindex, [:set, :protected])
local_iindex_b = :ets.new(:local_iindex, [:set, :protected])
local_mindex_a = :ets.new(:local_mindex, [:set, :protected])
local_mindex_b = :ets.new(:local_mindex, [:set, :protected])
Index.Generation.add_identity("blockstamp_test", local_iindex_a, local_mindex_a, %{
"pub" => "pub_toto",
"block_uid" => "block_uid_test",
"user_id" => "user_id_test"
})
Index.Generation.add_identity("blockstamp_test", local_iindex_b, local_mindex_b, %{
"pub" => "pub_toto",
"block_uid" => "block_uid_test",
"user_id" => "user_id_test"
})
{:ok, global_iindex_a} = :dets.open_file(:global_iindex_a, type: :set)
{:ok, global_iindex_b} = :dets.open_file(:global_iindex_b, type: :set)
:ets.to_dets(local_iindex_a, :global_iindex_a)
:ets.to_dets(local_iindex_b, :global_iindex_b)
[{"pub_toto", elt}] = :dets.lookup(:global_iindex_b, "pub_toto")
new_elt = Map.replace!(elt, :uid, "user_id_test_2")
:dets.insert(:global_iindex_b, {"pub_toto", new_elt})
Index.Augmentation.IIndex.uidUnique(local_iindex_a, global_iindex_a, "pub_toto")
Index.Augmentation.IIndex.uidUnique(local_iindex_b, global_iindex_b, "pub_toto")
identityUserIdUnicityTrue = Index.Augmentation.IIndex.identityUserIdUnicity(local_iindex_b, "pub_toto")
identityUserIdUnicityFalse = Index.Augmentation.IIndex.identityUserIdUnicity(local_iindex_a, "pub_toto")
:dets.close(global_iindex_a)
:file.delete("global_iindex_a")
:dets.close(global_iindex_b)
:file.delete("global_iindex_b")
{:ok, identityUserIdUnicityTrue: identityUserIdUnicityTrue, identityUserIdUnicityFalse: identityUserIdUnicityFalse}
end
test "check IdentityUserIdUnicity", state do
IO.puts("uid unique of b : #{state.identityUserIdUnicityTrue} and uid unique of a : #{state.identityUserIdUnicityFalse}")
assert state.identityUserIdUnicityTrue == true
assert state.identityUserIdUnicityFalse == false
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment