@@ -41,15 +41,17 @@ defmodule Phoenix.PubSubTest do
4141
4242 setup config do
4343 size = config [ :pool_size ] || 1
44+ registry_size = config [ :registry_size ] || config [ :registry_pool_size ] || config [ :pool_size ] || 1
4445 { adapter , adapter_opts } = Application . get_env ( :phoenix_pubsub , :test_adapter )
45- adapter_opts = [ adapter: adapter , name: config . test , pool_size: size ] ++ adapter_opts
46+ adapter_opts = [ adapter: adapter , name: config . test , pool_size: size , registry_size: registry_size ] ++ adapter_opts
4647 start_supervised! ( { Phoenix.PubSub , adapter_opts } )
4748
4849 opts = % {
4950 pubsub: config . test ,
5051 topic: to_string ( config . test ) ,
5152 pool_size: size ,
52- node: Phoenix.PubSub . node_name ( config . test )
53+ node: Phoenix.PubSub . node_name ( config . test ) ,
54+ adapter_name: Module . concat ( config . test , "Adapter" )
5355 }
5456
5557 { :ok , opts }
@@ -174,4 +176,23 @@ defmodule Phoenix.PubSubTest do
174176 assert_receive { :custom , :special , :none , :direct }
175177 end
176178 end
179+
180+ @ tag pool_size: 4
181+ @ tag registry_size: 2
182+ test "PubSub pool size can be configured separately from the Registry partitions" ,
183+ config do
184+ assert { :duplicate , 2 , _ } = :ets . lookup_element ( config . pubsub , - 2 , 2 )
185+
186+ assert :persistent_term . get ( config . adapter_name ) ==
187+ { config . adapter_name , :"#{ config . adapter_name } _2" , :"#{ config . adapter_name } _3" , :"#{ config . adapter_name } _4" }
188+ end
189+
190+ @ tag pool_size: 3
191+ test "Registry partitions are configured with the same pool size as PubSub if not specified" ,
192+ config do
193+ assert { :duplicate , 3 , _ } = :ets . lookup_element ( config . pubsub , - 2 , 2 )
194+
195+ assert :persistent_term . get ( config . adapter_name ) ==
196+ { config . adapter_name , :"#{ config . adapter_name } _2" , :"#{ config . adapter_name } _3" }
197+ end
177198end
0 commit comments