Skip to content

Commit d01c6fb

Browse files
committed
Address type-mismatch compiler warning in tests
1 parent 04dbc88 commit d01c6fb

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

test/fun_with_flags/notifications/phoenix_pubsub_test.exs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ defmodule FunWithFlags.Notifications.PhoenixPubSubTest do
6363
assert {:ok, _pid} = PubSub.publish_change(name)
6464

6565
payload = {:updated, name, u_id}
66-
66+
6767
receive do
6868
{:fwf_changes, ^payload} -> :ok
6969
after
@@ -104,7 +104,7 @@ defmodule FunWithFlags.Notifications.PhoenixPubSubTest do
104104
client = FunWithFlags.Config.pubsub_client()
105105
channel = "fun_with_flags_changes"
106106
message = {:fwf_changes, {:updated, :a_flag_name, u_id}}
107-
107+
108108
with_mock(Store, [:passthrough], []) do
109109
Phoenix.PubSub.broadcast!(client, channel, message)
110110
:timer.sleep(30)
@@ -120,7 +120,7 @@ defmodule FunWithFlags.Notifications.PhoenixPubSubTest do
120120
client = FunWithFlags.Config.pubsub_client()
121121
channel = "fun_with_flags_changes"
122122
message = {:fwf_changes, {:updated, :a_flag_name, another_u_id}}
123-
123+
124124
with_mock(Store, [:passthrough], []) do
125125
Phoenix.PubSub.broadcast!(client, channel, message)
126126
:timer.sleep(30)
@@ -149,18 +149,22 @@ defmodule FunWithFlags.Notifications.PhoenixPubSubTest do
149149
assert {:ok, ^stored_flag} = Config.persistence_adapter.get(name)
150150
assert {:ok, ^cached_flag} = Cache.get(name)
151151

152-
refute match? ^stored_flag, cached_flag
153-
154152
{:ok, name: name, stored_flag: stored_flag, cached_flag: cached_flag}
155153
end
156154

155+
# This should be in `setup` but in there it produces a compiler warning because
156+
# the two variables will never match (duh).
157+
test "verify test setup", %{cached_flag: cached_flag, stored_flag: stored_flag} do
158+
refute match? ^stored_flag, cached_flag
159+
end
160+
157161

158162
test "when the message comes from this same process, the Cached value is not changed", %{name: name, cached_flag: cached_flag} do
159163
u_id = PubSub.unique_id()
160164
client = FunWithFlags.Config.pubsub_client()
161165
channel = "fun_with_flags_changes"
162166
message = {:fwf_changes, {:updated, name, u_id}}
163-
167+
164168
Phoenix.PubSub.broadcast!(client, channel, message)
165169
:timer.sleep(30)
166170
assert {:ok, ^cached_flag} = Cache.get(name)
@@ -174,7 +178,7 @@ defmodule FunWithFlags.Notifications.PhoenixPubSubTest do
174178
client = FunWithFlags.Config.pubsub_client()
175179
channel = "fun_with_flags_changes"
176180
message = {:fwf_changes, {:updated, name, another_u_id}}
177-
181+
178182
assert {:ok, ^cached_flag} = Cache.get(name)
179183
Phoenix.PubSub.broadcast!(client, channel, message)
180184
:timer.sleep(30)

test/fun_with_flags/notifications/redis_test.exs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,15 @@ defmodule FunWithFlags.Notifications.RedisTest do
293293
assert {:ok, ^stored_flag} = PersiRedis.get(name)
294294
assert {:ok, ^cached_flag} = Cache.get(name)
295295

296-
refute match? ^stored_flag, cached_flag
297-
298296
{:ok, name: name, stored_flag: stored_flag, cached_flag: cached_flag}
299297
end
300298

299+
# This should be in `setup` but in there it produces a compiler warning because
300+
# the two variables will never match (duh).
301+
test "verify test setup", %{cached_flag: cached_flag, stored_flag: stored_flag} do
302+
refute match? ^stored_flag, cached_flag
303+
end
304+
301305

302306
test "when the message is not valid, the Cached value is not changed", %{name: name, cached_flag: cached_flag} do
303307
channel = "fun_with_flags_changes"

0 commit comments

Comments
 (0)