@@ -15,15 +15,34 @@ defmodule Phoenix.Sync.ApplicationTest do
1515 hostname: "localhost" ,
1616 database: "electric" ,
1717 port: 5432 ,
18- sslmode: :require ,
19- ipv6: true
18+ sslmode: :disable
2019 ]
2120
2221 expected_opts = Keyword . merge ( base_opts , overrides )
2322
2423 assert Enum . sort ( connection_opts ) == Enum . sort ( expected_opts )
2524 end
2625
26+ defp with_modified_config ( repo_config_overrides , fun ) do
27+ original_config = Application . get_env ( :phoenix_sync , Support.ConfigTestRepo , [ ] )
28+
29+ try do
30+ Application . put_env (
31+ :phoenix_sync ,
32+ Support.ConfigTestRepo ,
33+ Keyword . merge ( original_config , repo_config_overrides )
34+ )
35+
36+ fun . ( )
37+ after
38+ Application . put_env (
39+ :phoenix_sync ,
40+ Support.ConfigTestRepo ,
41+ original_config
42+ )
43+ end
44+ end
45+
2746 describe "children/1" do
2847 test "invalid mode" do
2948 assert { :error , _ } = App . children ( mode: :nonsense )
@@ -79,33 +98,40 @@ defmodule Phoenix.Sync.ApplicationTest do
7998 } = Map . new ( opts )
8099 end
81100
82- test "with defined port" do
83- original_config = Application . get_env ( :phoenix_sync , Support.ConfigTestRepo , [ ] )
101+ test "passes repo pg port to electric" do
102+ config = [
103+ env: :dev ,
104+ repo: Support.ConfigTestRepo
105+ ]
84106
85- override_port = 6543
107+ repo_override = [ port: 6543 ]
86108
109+ with_modified_config ( repo_override , fn ->
110+ assert { :ok , [ { Electric.StackSupervisor , opts } ] } = App . children ( config )
111+
112+ validate_repo_connection_opts! ( opts , repo_override )
113+ end )
114+ end
115+
116+ test "maps repo ssl and ipv6 settings to electric" do
87117 config = [
88118 env: :dev ,
89119 repo: Support.ConfigTestRepo
90120 ]
91121
92- try do
93- Application . put_env (
94- :phoenix_sync ,
95- Support.ConfigTestRepo ,
96- Keyword . put ( original_config , :port , override_port )
97- )
122+ repo_override = [
123+ ssl: true ,
124+ socket_options: [ :inet6 ]
125+ ]
98126
127+ with_modified_config ( repo_override , fn ->
99128 assert { :ok , [ { Electric.StackSupervisor , opts } ] } = App . children ( config )
100129
101- validate_repo_connection_opts! ( opts , port: override_port )
102- after
103- Application . put_env (
104- :phoenix_sync ,
105- Support.ConfigTestRepo ,
106- original_config
130+ validate_repo_connection_opts! ( opts ,
131+ sslmode: :require ,
132+ ipv6: true
107133 )
108- end
134+ end )
109135 end
110136
111137 test "only repo config given and electric installed defaults to embedded" do
0 commit comments