From 6fce83d7830fbae9a13cab4cd01e15232d7b545f Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:43:33 +0200 Subject: [PATCH] Test and warning fixes --- .gitignore | 1 + .../account/servers/client_server.ex | 2 +- .../battle/servers/match_monitor_server.ex | 20 +++++++++---------- lib/teiserver/benchmark/stats_client.ex | 2 +- lib/teiserver/bridge/command_lib.ex | 1 - lib/teiserver/bridge/message_commands.ex | 4 ++-- lib/teiserver/coordinator/consul_server.ex | 4 ++-- lib/teiserver/helpers/oban_logger.ex | 2 +- lib/teiserver/lobby/libs/lobby_lib.ex | 6 +++--- lib/teiserver/protocols/spring/spring_in.ex | 4 ++-- lib/teiserver/protocols/spring/spring_out.ex | 2 +- .../protocols/spring/spring_system_in.ex | 2 -- .../protocols/spring/spring_telemetry_in.ex | 4 ++-- lib/teiserver/protocols/tachyon_lib.ex | 4 ++-- .../protocols/tachyon_v1/communication_out.ex | 2 +- .../protocols/tachyon_v1/tachyon_out.ex | 2 +- .../live/battles/lobbies/chat.ex | 2 +- .../live/microblog/admin/post/show.ex | 1 - .../live/microblog/admin/tag/index.ex | 1 - .../live/microblog/admin/tag/show.ex | 1 - lib/teiserver_web/live/queues/index.ex | 2 +- test/teiserver/account/account_test.exs | 7 ------- .../coordinator/consul_commands_test.exs | 20 +++++++++---------- .../coordinator/coordinator_commands_test.exs | 12 +++++------ .../coordinator/match_monitor_server_test.exs | 6 +++--- test/teiserver/coordinator/memes_test.exs | 10 +++++----- .../teiserver/coordinator/moderation_test.exs | 14 ++++++------- .../spring/spring_telemetry_test.exs | 18 ++++++++--------- .../complex_client_event_controller_test.exs | 2 +- .../live/microblog/blog/index_live_test.exs | 6 +++--- 30 files changed, 76 insertions(+), 88 deletions(-) diff --git a/.gitignore b/.gitignore index 06cd03941..1ae518ebd 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ runtime/ /source_deploy.tar.gz central.tar.gz /bin +.vscode/launch.json # I'm storing server output here, don't want to push it to git example_output diff --git a/lib/teiserver/account/servers/client_server.ex b/lib/teiserver/account/servers/client_server.ex index 5855858b8..b5bb0d29b 100644 --- a/lib/teiserver/account/servers/client_server.ex +++ b/lib/teiserver/account/servers/client_server.ex @@ -114,7 +114,7 @@ defmodule Teiserver.Account.ClientServer do end def handle_cast({:merge_update_client, partial_client}, state) do - Logger.warn(":merge_update_client is still being used, instead use :update_values") + Logger.warning(":merge_update_client is still being used, instead use :update_values") new_client = Map.merge(state.client, partial_client) PubSub.broadcast( diff --git a/lib/teiserver/battle/servers/match_monitor_server.ex b/lib/teiserver/battle/servers/match_monitor_server.ex index 770534678..91a0c2508 100644 --- a/lib/teiserver/battle/servers/match_monitor_server.ex +++ b/lib/teiserver/battle/servers/match_monitor_server.ex @@ -155,10 +155,10 @@ defmodule Teiserver.Battle.MatchMonitorServer do Telemetry.log_simple_match_event(userid, match_id, event_type_name, game_time) Logger.info("match-event: Stored <#{username}> <#{event_type_name}> <#{game_time}> userid #{userid} match_id #{match_id}") else - Logger.warn("match-event: Cannot get match_id of userid of #{username}") + Logger.warning("match-event: Cannot get match_id of userid of #{username}") end else - Logger.warn("match-event: Cannot get userid of #{username} or is not a bot") + Logger.warning("match-event: Cannot get userid of #{username} or is not a bot") end _ -> @@ -242,7 +242,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do end _ -> - Logger.warn("match-chat nomatch from: #{from_id}: match-chat #{data}") + Logger.warning("match-chat nomatch from: #{from_id}: match-chat #{data}") end {:noreply, state} @@ -288,7 +288,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do end _ -> - Logger.warn("match-chat-name nomatch from: #{from_id}: match-chat [[#{data}]]") + Logger.warning("match-chat-name nomatch from: #{from_id}: match-chat [[#{data}]]") end {:noreply, state} @@ -311,15 +311,15 @@ defmodule Teiserver.Battle.MatchMonitorServer do handle_json_msg(data, from_id) _ -> - Logger.warn("AHM DM no catch, no json-decode - '#{contents_string}'") + Logger.warning("AHM DM no catch, no json-decode - '#{contents_string}'") end _ -> - Logger.warn("AHM DM no catch, no decompress - '#{compressed_contents}'") + Logger.warning("AHM DM no catch, no decompress - '#{compressed_contents}'") end _ -> - Logger.warn("AHM DM no catch, no base64 - '#{message}'") + Logger.warning("AHM DM no catch, no base64 - '#{message}'") end {:noreply, state} @@ -327,7 +327,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do # Catchall handle_info def handle_info(msg, state) do - Logger.warn( + Logger.warning( "Match monitor Server handle_info error. No handler for msg of #{Kernel.inspect(msg)}" ) @@ -337,7 +337,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do defp handle_json_msg(%{"username" => username, "GPU" => _} = contents, from_id) do case CacheUser.get_user_by_name(username) do nil -> - Logger.warn("No username on handle_json_msg: #{username} - #{Kernel.inspect(contents)}") + Logger.warning("No username on handle_json_msg: #{username} - #{Kernel.inspect(contents)}") :ok @@ -367,7 +367,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do end defp handle_json_msg(contents, _from_id) do - Logger.warn("No catch on handle_json_msg: #{Kernel.inspect(contents)}") + Logger.warning("No catch on handle_json_msg: #{Kernel.inspect(contents)}") :ok end diff --git a/lib/teiserver/benchmark/stats_client.ex b/lib/teiserver/benchmark/stats_client.ex index 6a2c88a95..8c78a49c9 100644 --- a/lib/teiserver/benchmark/stats_client.ex +++ b/lib/teiserver/benchmark/stats_client.ex @@ -43,7 +43,7 @@ Avg ping: #{round(average_ping * 100) / 100}ms, Pings: #{Enum.count(state.pings) port: port }) - Logger.warn("Starting stats") + Logger.warning("Starting stats") :timer.send_interval(@registration_interval, self(), :register) send(self(), :register) diff --git a/lib/teiserver/bridge/command_lib.ex b/lib/teiserver/bridge/command_lib.ex index 8034bc149..7332d0333 100644 --- a/lib/teiserver/bridge/command_lib.ex +++ b/lib/teiserver/bridge/command_lib.ex @@ -2,7 +2,6 @@ defmodule Teiserver.Bridge.CommandLib do @moduledoc """ """ - alias Teiserver.Data.Types, as: T require Logger @spec handle_command(Nostrum.Struct.Interaction.t(), map()) :: map() diff --git a/lib/teiserver/bridge/message_commands.ex b/lib/teiserver/bridge/message_commands.ex index a6a21dda2..d0734d28c 100644 --- a/lib/teiserver/bridge/message_commands.ex +++ b/lib/teiserver/bridge/message_commands.ex @@ -17,7 +17,7 @@ defmodule Teiserver.Bridge.MessageCommands do content: "$" <> content, attachments: [] }) do - Logger.warn("1") + Logger.warning("1") [cmd | remaining] = String.split(content, " ") remaining = Enum.join(remaining, " ") @@ -45,7 +45,7 @@ defmodule Teiserver.Bridge.MessageCommands do end def handle(_msg) do - # Logger.warn("2") + # Logger.warning("2") # IO.inspect msg :ok diff --git a/lib/teiserver/coordinator/consul_server.ex b/lib/teiserver/coordinator/consul_server.ex index 75d5eca7c..fc15bd7fd 100644 --- a/lib/teiserver/coordinator/consul_server.ex +++ b/lib/teiserver/coordinator/consul_server.ex @@ -657,7 +657,7 @@ defmodule Teiserver.Coordinator.ConsulServer do # if existing.ready == false and new_client.ready == true and existing.unready_at != nil do # time_elapsed = System.system_time(:millisecond) - existing.unready_at # if time_elapsed < 1000 do - # Logger.warn("Ready up in #{time_elapsed}ms by #{existing.userid}/#{existing.name} using #{existing.lobby_client}") + # Logger.warning("Ready up in #{time_elapsed}ms by #{existing.userid}/#{existing.name} using #{existing.lobby_client}") # end # end @@ -686,7 +686,7 @@ defmodule Teiserver.Coordinator.ConsulServer do if player_count > 4 do if user.hw_hash == nil do - Logger.warn("hw hash block for #{Account.get_username(userid)}") + Logger.warning("hw hash block for #{Account.get_username(userid)}") %{new_client | player: false} else new_client diff --git a/lib/teiserver/helpers/oban_logger.ex b/lib/teiserver/helpers/oban_logger.ex index 6f969df33..77975c63d 100644 --- a/lib/teiserver/helpers/oban_logger.ex +++ b/lib/teiserver/helpers/oban_logger.ex @@ -3,7 +3,7 @@ defmodule Teiserver.Helper.ObanLogger do require Logger def handle_event([:oban, :job, :start], _measure, _meta, _) do - # Logger.warn("[Oban] :started #{meta.worker} at #{measure.system_time}") + # Logger.warning("[Oban] :started #{meta.worker} at #{measure.system_time}") end def handle_event([:oban, :job, :exception], _measure, meta, _) do diff --git a/lib/teiserver/lobby/libs/lobby_lib.ex b/lib/teiserver/lobby/libs/lobby_lib.ex index dfcbd4089..130699009 100644 --- a/lib/teiserver/lobby/libs/lobby_lib.ex +++ b/lib/teiserver/lobby/libs/lobby_lib.ex @@ -199,14 +199,14 @@ defmodule Teiserver.Lobby.LobbyLib do @spec update_lobby(T.lobby(), nil | atom, any) :: T.lobby() def update_lobby(%{id: lobby_id} = lobby, nil, :silent) do - Logger.warn("update_lobby is still being called for :silent") + Logger.warning("update_lobby is still being called for :silent") cast_lobby(lobby_id, {:update_lobby, lobby}) lobby end def update_lobby(%{id: lobby_id} = lobby, nil, reason) do - Logger.warn("update_lobby (no data) is still being called, reason: #{reason}") + Logger.warning("update_lobby (no data) is still being called, reason: #{reason}") cast_lobby(lobby_id, {:update_lobby, lobby}) PubSub.broadcast( @@ -224,7 +224,7 @@ defmodule Teiserver.Lobby.LobbyLib do end def update_lobby(%{id: lobby_id} = lobby, data, reason) do - Logger.warn("update_lobby (with data) is still being called, reason: #{reason}") + Logger.warning("update_lobby (with data) is still being called, reason: #{reason}") cast_lobby(lobby_id, {:update_lobby, lobby}) if Enum.member?([:update_battle_info], reason) do diff --git a/lib/teiserver/protocols/spring/spring_in.ex b/lib/teiserver/protocols/spring/spring_in.ex index 34a55fdb5..cd73a602d 100644 --- a/lib/teiserver/protocols/spring/spring_in.ex +++ b/lib/teiserver/protocols/spring/spring_in.ex @@ -1408,11 +1408,11 @@ defmodule Teiserver.Protocols.SpringIn do cond do Enum.count(status_timestamps) > 10 -> - Logger.warn("status_flood_protection:10 - #{state.username}/#{state.userid}") + Logger.warning("status_flood_protection:10 - #{state.username}/#{state.userid}") {true, %{state | status_timestamps: status_timestamps}} Enum.count(recent_timestamps) > 3 -> - Logger.warn("status_flood_protection:3 - #{state.username}/#{state.userid}") + Logger.warning("status_flood_protection:3 - #{state.username}/#{state.userid}") {true, %{state | status_timestamps: status_timestamps}} true -> diff --git a/lib/teiserver/protocols/spring/spring_out.ex b/lib/teiserver/protocols/spring/spring_out.ex index 4989f8c11..ec08fe695 100644 --- a/lib/teiserver/protocols/spring/spring_out.ex +++ b/lib/teiserver/protocols/spring/spring_out.ex @@ -855,7 +855,7 @@ defmodule Teiserver.Protocols.SpringOut do # I've made the mistake of forgetting it and wondering # why stuff wasn't working so it's staying here if not String.ends_with?(msg, "\n") do - Logger.warn("Attempting to send message without newline at the end - #{msg}") + Logger.warning("Attempting to send message without newline at the end - #{msg}") end msg = diff --git a/lib/teiserver/protocols/spring/spring_system_in.ex b/lib/teiserver/protocols/spring/spring_system_in.ex index be7c41230..c83271e6e 100644 --- a/lib/teiserver/protocols/spring/spring_system_in.ex +++ b/lib/teiserver/protocols/spring/spring_system_in.ex @@ -1,9 +1,7 @@ defmodule Teiserver.Protocols.Spring.SystemIn do @moduledoc false - alias Teiserver.Account.LoginThrottleServer alias Teiserver.Protocols.SpringIn - import Teiserver.Protocols.SpringOut, only: [reply: 5] require Logger @spec do_handle(String.t(), String.t(), String.t() | nil, Map.t()) :: Map.t() diff --git a/lib/teiserver/protocols/spring/spring_telemetry_in.ex b/lib/teiserver/protocols/spring/spring_telemetry_in.ex index 798710551..b867d04ce 100644 --- a/lib/teiserver/protocols/spring/spring_telemetry_in.ex +++ b/lib/teiserver/protocols/spring/spring_telemetry_in.ex @@ -156,9 +156,9 @@ defmodule Teiserver.Protocols.Spring.TelemetryIn do defp do_live_client_event(data, state) do if String.length(data) < 1024 do case Regex.run(~r/(\S+) (\S+)/u, data) do - [_, event_name, value64] -> + [_, _event_name, value64] -> case Spring.decode_value(value64) do - {:ok, value} -> + {:ok, _value} -> if state.userid do # TODO: Do stuff with live client events # Telemetry.log_live_client_event(state.userid, event_name, value) diff --git a/lib/teiserver/protocols/tachyon_lib.ex b/lib/teiserver/protocols/tachyon_lib.ex index a6b3b77d7..3ef48e818 100644 --- a/lib/teiserver/protocols/tachyon_lib.ex +++ b/lib/teiserver/protocols/tachyon_lib.ex @@ -56,11 +56,11 @@ defmodule Teiserver.Protocols.TachyonLib do :error -> # Previously got an error with data 'OK cmd=TACHYON' which suggests # it was still in Spring mode - Logger.warn("Base64 error, given '#{data}'") + Logger.warning("Base64 error, given '#{data}'") {:error, :base64_decode} {:error, :gzip_decompress} -> - Logger.warn("Gzip error, given '#{data}'") + Logger.warning("Gzip error, given '#{data}'") {:error, :gzip_decompress} {:error, %Jason.DecodeError{}} -> diff --git a/lib/teiserver/protocols/tachyon_v1/communication_out.ex b/lib/teiserver/protocols/tachyon_v1/communication_out.ex index 533e1afe8..9b9e7fb4a 100644 --- a/lib/teiserver/protocols/tachyon_v1/communication_out.ex +++ b/lib/teiserver/protocols/tachyon_v1/communication_out.ex @@ -7,7 +7,7 @@ defmodule Teiserver.Protocols.Tachyon.V1.CommunicationOut do ########### # Direct messages def do_reply(:direct_message, {sender_id, msg}) do - Logger.warn( + Logger.warning( "Using :direct_message instead of :received_direct_message in V1.CommunicationOut" ) diff --git a/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex b/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex index 62765c7be..5f709c6ec 100644 --- a/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex +++ b/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex @@ -43,7 +43,7 @@ defmodule Teiserver.Protocols.Tachyon.V1.TachyonOut do LobbyOut.do_reply(reply_cmd, data) :battle -> - Logger.warn("Tachyon :battle namespace message #{reply_cmd}") + Logger.warning("Tachyon :battle namespace message #{reply_cmd}") LobbyOut.do_reply(reply_cmd, data) :matchmaking -> diff --git a/lib/teiserver_web/live/battles/lobbies/chat.ex b/lib/teiserver_web/live/battles/lobbies/chat.ex index 00a6e33c8..e60d5b216 100644 --- a/lib/teiserver_web/live/battles/lobbies/chat.ex +++ b/lib/teiserver_web/live/battles/lobbies/chat.ex @@ -245,7 +245,7 @@ defmodule TeiserverWeb.Battle.LobbyLive.Chat do end def handle_info(msg, socket) do - Logger.warn("No handler in #{__MODULE__} for message #{Kernel.inspect(msg)}") + Logger.warning("No handler in #{__MODULE__} for message #{Kernel.inspect(msg)}") {:noreply, socket} end diff --git a/lib/teiserver_web/live/microblog/admin/post/show.ex b/lib/teiserver_web/live/microblog/admin/post/show.ex index 46e0ec5fc..c98e3a7ed 100644 --- a/lib/teiserver_web/live/microblog/admin/post/show.ex +++ b/lib/teiserver_web/live/microblog/admin/post/show.ex @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.PostLive.Show do @moduledoc false use TeiserverWeb, :live_view alias Teiserver.Microblog - import TeiserverWeb.MicroblogComponents @impl true def mount(_params, _session, socket) do diff --git a/lib/teiserver_web/live/microblog/admin/tag/index.ex b/lib/teiserver_web/live/microblog/admin/tag/index.ex index 965fca837..3557d46f7 100644 --- a/lib/teiserver_web/live/microblog/admin/tag/index.ex +++ b/lib/teiserver_web/live/microblog/admin/tag/index.ex @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.TagLive.Index do @moduledoc false use TeiserverWeb, :live_view alias Teiserver.Microblog - import TeiserverWeb.MicroblogComponents @impl true def mount(_params, _session, socket) do diff --git a/lib/teiserver_web/live/microblog/admin/tag/show.ex b/lib/teiserver_web/live/microblog/admin/tag/show.ex index 54a0540bc..1f8ca4359 100644 --- a/lib/teiserver_web/live/microblog/admin/tag/show.ex +++ b/lib/teiserver_web/live/microblog/admin/tag/show.ex @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.TagLive.Show do @moduledoc false use TeiserverWeb, :live_view alias Teiserver.Microblog - import TeiserverWeb.MicroblogComponents @impl true def mount(_params, _session, socket) do diff --git a/lib/teiserver_web/live/queues/index.ex b/lib/teiserver_web/live/queues/index.ex index ad7c47955..380952fc8 100644 --- a/lib/teiserver_web/live/queues/index.ex +++ b/lib/teiserver_web/live/queues/index.ex @@ -206,7 +206,7 @@ defmodule TeiserverWeb.Matchmaking.QueueLive.Index do } = data, socket ) do - Logger.warn("index.ex Match ready") + Logger.warning("index.ex Match ready") {:noreply, socket diff --git a/test/teiserver/account/account_test.exs b/test/teiserver/account/account_test.exs index dbafaf806..5ed055818 100644 --- a/test/teiserver/account/account_test.exs +++ b/test/teiserver/account/account_test.exs @@ -78,13 +78,6 @@ defmodule Teiserver.AccountTest do developer: "Normal" ] ) - - # Order by - Account.list_users(order_by: [{:data, "field", :asc}]) - Account.list_users(order_by: [{:data, "field", :desc}]) - - # Fallback - Account.list_users(order_by: [{:data, "field", :desc}]) end test "get_user!/1 returns the user with given id" do diff --git a/test/teiserver/coordinator/consul_commands_test.exs b/test/teiserver/coordinator/consul_commands_test.exs index 48bee636a..b367de54e 100644 --- a/test/teiserver/coordinator/consul_commands_test.exs +++ b/test/teiserver/coordinator/consul_commands_test.exs @@ -456,13 +456,13 @@ defmodule Teiserver.Coordinator.ConsulCommandsTest do # Minimum assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 0 - data = %{cmd: "c.lobby.message", message: "$minplaylevel 3"} + data = %{cmd: "c.lobby.message", message: "$minratinglevel 3"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 3 - data = %{cmd: "c.lobby.message", message: "$minplaylevel Xy"} + data = %{cmd: "c.lobby.message", message: "$minratinglevel Xy"} _tachyon_send(hsocket, data) :timer.sleep(500) @@ -471,52 +471,52 @@ defmodule Teiserver.Coordinator.ConsulCommandsTest do # Maximum assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 1000 - data = %{cmd: "c.lobby.message", message: "$maxplaylevel 13"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel 13"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13 - data = %{cmd: "c.lobby.message", message: "$maxplaylevel Xy"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel Xy"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13 # Now try to set each the other side of the other - data = %{cmd: "c.lobby.message", message: "$maxplaylevel 1"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel 1"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 4 - data = %{cmd: "c.lobby.message", message: "$maxplaylevel 16"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel 16"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 16 - data = %{cmd: "c.lobby.message", message: "$minplaylevel 20"} + data = %{cmd: "c.lobby.message", message: "$minratinglevel 20"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 15 - data = %{cmd: "c.lobby.message", message: "$setplaylevels 7 9"} + data = %{cmd: "c.lobby.message", message: "$setratinglevels 7 9"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 7 assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 9 - data = %{cmd: "c.lobby.message", message: "$setplaylevels 50 33"} + data = %{cmd: "c.lobby.message", message: "$setratinglevels 50 33"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 33 assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 50 - data = %{cmd: "c.lobby.message", message: "$resetplaylevels"} + data = %{cmd: "c.lobby.message", message: "$resetratinglevels"} _tachyon_send(hsocket, data) :timer.sleep(500) diff --git a/test/teiserver/coordinator/coordinator_commands_test.exs b/test/teiserver/coordinator/coordinator_commands_test.exs index eb5667a17..c8f79fd0a 100644 --- a/test/teiserver/coordinator/coordinator_commands_test.exs +++ b/test/teiserver/coordinator/coordinator_commands_test.exs @@ -1,6 +1,6 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do use Teiserver.ServerCase, async: false - alias Teiserver.{User, Coordinator, Account} + alias Teiserver.{CacheUser, Coordinator, Account} import Teiserver.TeiserverTestLib, only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1, new_user: 0] @@ -44,7 +44,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do assert String.contains?(message, "$whoami") # Moderator help test - User.update_user(%{user | moderator: true}) + CacheUser.update_user(%{user | moderator: true}) message_coordinator(socket, "$help") [reply] = _tachyon_recv(socket) assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} @@ -94,7 +94,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do refute String.contains?(message, "Displays this help text.") # Moderator pull test - User.update_user(%{user | moderator: true}) + CacheUser.update_user(%{user | moderator: true}) message_coordinator(socket, "$help pull") [reply] = _tachyon_recv(socket) assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} @@ -195,7 +195,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do "sender_id" => coordinator_userid } - user = User.get_user_by_id(user.id) + user = CacheUser.get_user_by_id(user.id) assert user.ignored == [user2.id] # Now use it again, make sure we don't get a crash @@ -211,7 +211,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do "sender_id" => coordinator_userid } - user = User.get_user_by_id(user.id) + user = CacheUser.get_user_by_id(user.id) assert user.ignored == [] # Now unmute again @@ -227,7 +227,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do "sender_id" => coordinator_userid } - user = User.get_user_by_id(user.id) + user = CacheUser.get_user_by_id(user.id) assert user.ignored == [] end diff --git a/test/teiserver/coordinator/match_monitor_server_test.exs b/test/teiserver/coordinator/match_monitor_server_test.exs index 6bb8225ee..34bee7a12 100644 --- a/test/teiserver/coordinator/match_monitor_server_test.exs +++ b/test/teiserver/coordinator/match_monitor_server_test.exs @@ -1,6 +1,6 @@ defmodule Teiserver.Coordinator.MatchMonitorServerTest do use Teiserver.ServerCase, async: false - alias Teiserver.{User, Chat, Client, Lobby} + alias Teiserver.{CacheUser, Chat, Client, Lobby} alias Teiserver.Coordinator.{CoordinatorServer} import Teiserver.TeiserverTestLib, @@ -13,7 +13,7 @@ defmodule Teiserver.Coordinator.MatchMonitorServerTest do Teiserver.Battle.start_match_monitor() %{socket: hsocket, user: host} = tachyon_auth_setup() %{socket: psocket, user: player} = tachyon_auth_setup() - User.update_user(%{host | bot: true}) + CacheUser.update_user(%{host | bot: true}) battle_data = %{ cmd: "c.lobby.create", @@ -56,7 +56,7 @@ defmodule Teiserver.Coordinator.MatchMonitorServerTest do end test "chat messages", %{hsocket: hsocket, host: host, player: player} do - monitor_user = User.get_user_by_name("AutohostMonitor") + monitor_user = CacheUser.get_user_by_name("AutohostMonitor") messages1 = Chat.list_lobby_messages(search: [user_id: host.id]) messages2 = Chat.list_lobby_messages(search: [user_id: player.id]) diff --git a/test/teiserver/coordinator/memes_test.exs b/test/teiserver/coordinator/memes_test.exs index 2feb8aa68..d467b1835 100644 --- a/test/teiserver/coordinator/memes_test.exs +++ b/test/teiserver/coordinator/memes_test.exs @@ -1,7 +1,7 @@ defmodule Teiserver.Coordinator.MemesTest do use Teiserver.ServerCase, async: false alias Teiserver.Account.ClientLib - alias Teiserver.{User, Client, Coordinator, Lobby} + alias Teiserver.{CacheUser, Client, Coordinator, Lobby} require Logger import Teiserver.TeiserverTestLib, @@ -13,7 +13,7 @@ defmodule Teiserver.Coordinator.MemesTest do %{socket: psocket, user: player} = tachyon_auth_setup() # User needs to be a moderator (at this time) to start/stop Coordinator mode - User.update_user(%{host | moderator: true}) + CacheUser.update_user(%{host | moderator: true}) ClientLib.refresh_client(host.id) lobby_data = %{ @@ -73,7 +73,7 @@ defmodule Teiserver.Coordinator.MemesTest do assert reply == %{ "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, + "lobby_id" => lobby_id, "new_values" => %{ "disabled_units" => ~w(armaap armalab armap armavp armhp armshltx armvp armamsub armasy armfhp armplat armshltxuw armsy armmg armllt armbeamer armhlt arm armdrag armclaw armguard armjuno armham armjeth armpw armrectr armrock armwar coraap coralab corap coravp corgant corhp corlab corvp corllt corfhp corsy corjuno corhllt corhlt) @@ -102,7 +102,7 @@ defmodule Teiserver.Coordinator.MemesTest do "cmd" => "s.lobby.set_modoptions", "lobby_id" => lobby_id, "new_options" => %{ - "game/modoptions/resourceincomemultiplier" => "0" + "game/modoptions/multiplier_resourceincome" => "0" } } end @@ -115,7 +115,7 @@ defmodule Teiserver.Coordinator.MemesTest do "cmd" => "s.lobby.set_modoptions", "lobby_id" => lobby_id, "new_options" => %{ - "game/modoptions/resourceincomemultiplier" => "1000", + "game/modoptions/multiplier_resourceincome" => "1000", "game/modoptions/startenergy" => "100000000", "game/modoptions/startmetal" => "100000000" } diff --git a/test/teiserver/coordinator/moderation_test.exs b/test/teiserver/coordinator/moderation_test.exs index 738ba88a6..64b2d0aee 100644 --- a/test/teiserver/coordinator/moderation_test.exs +++ b/test/teiserver/coordinator/moderation_test.exs @@ -1,6 +1,6 @@ defmodule Teiserver.Coordinator.ModerationTest do use Teiserver.ServerCase, async: false - alias Teiserver.{User, Coordinator, Client, Moderation} + alias Teiserver.{CacheUser, Coordinator, Client, Moderation} import Teiserver.Helper.TimexHelper, only: [date_to_str: 2] alias Teiserver.Moderation.RefreshUserRestrictionsTask @@ -16,9 +16,9 @@ defmodule Teiserver.Coordinator.ModerationTest do test "login with warning", %{user: user} do delay = Teiserver.Config.get_site_config_cache("teiserver.Post login action delay") - refute User.has_warning?(user.id) - refute User.has_mute?(user.id) - refute User.is_restricted?(user.id, ["Login"]) + refute CacheUser.has_warning?(user.id) + refute CacheUser.has_mute?(user.id) + refute CacheUser.is_restricted?(user.id, ["Login"]) {:ok, action} = Moderation.create_action(%{ @@ -33,9 +33,9 @@ defmodule Teiserver.Coordinator.ModerationTest do RefreshUserRestrictionsTask.refresh_user(user.id) # Did it take? - assert User.has_warning?(user.id) - refute User.has_mute?(user.id) - refute User.is_restricted?(user.id, ["Login"]) + assert CacheUser.has_warning?(user.id) + refute CacheUser.has_mute?(user.id) + refute CacheUser.is_restricted?(user.id, ["Login"]) # Now login %{socket: socket} = tachyon_auth_setup(user) diff --git a/test/teiserver/protocols/spring/spring_telemetry_test.exs b/test/teiserver/protocols/spring/spring_telemetry_test.exs index 4d75fe6cf..2739f06fa 100644 --- a/test/teiserver/protocols/spring/spring_telemetry_test.exs +++ b/test/teiserver/protocols/spring/spring_telemetry_test.exs @@ -100,16 +100,16 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_events()) == 0 - assert Enum.count(Telemetry.list_client_events()) == 0 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 + assert Enum.count(Telemetry.list_complex_client_events()) == 0 # Good data _send_raw(socket, "c.telemetry.log_client_event event_name e30= TXlWYWx1ZUdvZXNoZXJl\n") reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_events()) == 0 - assert Enum.count(Telemetry.list_client_events()) == 1 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 + assert Enum.count(Telemetry.list_complex_client_events()) == 1 # Unauth %{socket: socket_raw} = raw_setup() @@ -118,8 +118,8 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket_raw) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_events()) == 1 - assert Enum.count(Telemetry.list_client_events()) == 1 + assert Enum.count(Telemetry.list_complex_anon_events()) == 1 + assert Enum.count(Telemetry.list_complex_client_events()) == 1 end test "update_client_property call", %{socket: socket} do @@ -132,7 +132,7 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_properties()) == 0 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 assert Enum.count(Telemetry.list_client_properties()) == 0 # Good data @@ -144,7 +144,7 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_properties()) == 0 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 assert Enum.count(Telemetry.list_client_properties()) == 1 # Unauth @@ -159,7 +159,7 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket_raw) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_properties()) == 1 + assert Enum.count(Telemetry.list_complex_anon_events()) == 1 assert Enum.count(Telemetry.list_client_properties()) == 1 end end diff --git a/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs b/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs index ad465186e..6c14e0949 100644 --- a/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs +++ b/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs @@ -9,7 +9,7 @@ defmodule TeiserverWeb.Report.ComplexClientEventControllerTest do end test "index", %{conn: conn} do - conn = get(conn, ~p"/telemetry/complex_client/summary") + conn = get(conn, ~p"/telemetry/complex_client_events/summary") assert html_response(conn, 200) end diff --git a/test/teiserver_web/live/microblog/blog/index_live_test.exs b/test/teiserver_web/live/microblog/blog/index_live_test.exs index 6ba5f660e..f6137ea31 100644 --- a/test/teiserver_web/live/microblog/blog/index_live_test.exs +++ b/test/teiserver_web/live/microblog/blog/index_live_test.exs @@ -17,15 +17,15 @@ defmodule TeiserverWeb.Microblog.Blog.IndexLiveTest do tag2 = tag_fixture() tag3 = tag_fixture() - post1 = post_fixture(title: "Post 1 title", contents: "Post 1 line1\n\nPost 1 fold line") + post1 = post_fixture(title: "Post 1 title", summary: "Post 1 line1", contents: "Post 1 line1\n\nPost 1 fold line") _post1_tag1 = post_tag_fixture(post_id: post1.id, tag_id: tag1.id) _post1_tag2 = post_tag_fixture(post_id: post1.id, tag_id: tag2.id) - post2 = post_fixture(title: "Post 2 title", contents: "Post 2 line1\n\nPost 2 fold line") + post2 = post_fixture(title: "Post 2 title", summary: "Post 2 line1", contents: "Post 2 line1\n\nPost 2 fold line") _post2_tag1 = post_tag_fixture(post_id: post2.id, tag_id: tag1.id) _post2_tag3 = post_tag_fixture(post_id: post2.id, tag_id: tag3.id) - post3 = post_fixture(title: "Post 3 title", contents: "Post 3 line1\n\nPost 3 fold line") + post3 = post_fixture(title: "Post 3 title", summary: "Post 3 line1", contents: "Post 3 line1\n\nPost 3 fold line") _post3_tag2 = post_tag_fixture(post_id: post3.id, tag_id: tag2.id) _post3_tag3 = post_tag_fixture(post_id: post3.id, tag_id: tag3.id)