From 3ed89a19f18dd99358de536172aee5db40db3189 Mon Sep 17 00:00:00 2001 From: Marcel Otto Date: Mon, 21 Mar 2022 21:43:58 +0100 Subject: [PATCH] Add BlankNode.Generator test with name via registry --- test/unit/resource_generator_test.exs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/resource_generator_test.exs b/test/unit/resource_generator_test.exs index fcd4282..aba5514 100644 --- a/test/unit/resource_generator_test.exs +++ b/test/unit/resource_generator_test.exs @@ -38,5 +38,19 @@ defmodule RDF.ResourceId.GeneratorTest do assert Generator.generate(config, "test2") == RDF.bnode(1) assert Generator.generate(config, "test1") == RDF.bnode(0) end + + test "via Registry" do + {:ok, _} = start_supervised({Registry, [keys: :unique, name: Registry.ViaTest]}) + + name = {:via, Registry, {Registry.ViaTest, "bnode-generator-via-test"}} + + {:ok, _} = + start_supervised({RDF.BlankNode.Generator, {RDF.BlankNode.Increment, [name: name]}}) + + config = [generator: BlankNode.Generator, pid: name] + + assert Generator.generate(config) == RDF.bnode(0) + assert Generator.generate(config) == RDF.bnode(1) + end end end