mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -5,64 +5,6 @@
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
integer_list_to_binaries_test() ->
|
||||
?assertEqual([<<"1">>, <<"2">>, <<"3">>], call_state:integer_list_to_binaries([1, 2, 3])),
|
||||
?assertEqual([], call_state:integer_list_to_binaries([])).
|
||||
|
||||
find_session_by_pid_test() ->
|
||||
Pid1 = self(),
|
||||
Sessions = #{
|
||||
<<"session1">> => {100, Pid1, make_ref()},
|
||||
<<"session2">> => {200, spawn(fun() -> ok end), make_ref()}
|
||||
},
|
||||
?assertMatch({ok, <<"session1">>, 100}, call_state:find_session_by_pid(Pid1, Sessions)),
|
||||
?assertEqual(not_found, call_state:find_session_by_pid(spawn(fun() -> ok end), Sessions)).
|
||||
|
||||
format_voice_state_test() ->
|
||||
VoiceState = #{
|
||||
<<"user_id">> => 123,
|
||||
<<"channel_id">> => 456,
|
||||
<<"guild_id">> => 789,
|
||||
<<"mute">> => false
|
||||
},
|
||||
Result = call_state:format_voice_state(VoiceState),
|
||||
?assertEqual(<<"123">>, maps:get(<<"user_id">>, Result)),
|
||||
?assertEqual(<<"456">>, maps:get(<<"channel_id">>, Result)),
|
||||
?assertEqual(<<"789">>, maps:get(<<"guild_id">>, Result)),
|
||||
?assertEqual(false, maps:get(<<"mute">>, Result)).
|
||||
|
||||
format_pending_connections_normalizes_and_filters_malformed_entries_test() ->
|
||||
PendingConnections = #{
|
||||
<<"conn-a">> => #{user_id => <<"42">>, token_nonce => 123, joined_at => <<"1000">>},
|
||||
"conn-b" => #{user_id => "84", token_nonce => "nonce", joined_at => "2000"},
|
||||
<<"missing-user">> => #{token_nonce => <<"nonce">>, joined_at => 1000},
|
||||
<<"bad-user">> => #{user_id => <<"bad">>, joined_at => 1000},
|
||||
<<"leading-zero-user">> => #{user_id => <<"0042">>, joined_at => 1000},
|
||||
<<"leading-zero-list-user">> => #{user_id => "0084", joined_at => 1000},
|
||||
<<"bad-joined-at">> => #{user_id => 168, joined_at => <<"bad">>},
|
||||
<<"not-a-map">> => not_a_map
|
||||
},
|
||||
Result = call_state:format_pending_connections(PendingConnections),
|
||||
?assertEqual(3, length(Result)),
|
||||
?assert(
|
||||
has_pending_connection(
|
||||
#{connection_id => <<"conn-a">>, user_id => <<"42">>, token_nonce => <<"123">>},
|
||||
Result
|
||||
)
|
||||
),
|
||||
?assert(
|
||||
has_pending_connection(
|
||||
#{connection_id => <<"conn-b">>, user_id => <<"84">>, token_nonce => <<"nonce">>},
|
||||
Result
|
||||
)
|
||||
),
|
||||
?assert(
|
||||
has_pending_connection(
|
||||
#{connection_id => <<"bad-joined-at">>, user_id => <<"168">>}, Result
|
||||
)
|
||||
),
|
||||
?assertEqual([], call_state:format_pending_connections(not_a_map)).
|
||||
|
||||
remove_users_from_ringing_test() ->
|
||||
State = new_call_test_state(#{
|
||||
ringing => [1, 2, 3],
|
||||
@@ -274,32 +216,6 @@ leave_removes_voice_state_count_without_full_rebuild_test() ->
|
||||
?assertEqual(0, voice_count(<<"servers">>, <<"server_id">>, ServerId)),
|
||||
ok = voice_state_counts_cache:remove_connection(ConnectionId).
|
||||
|
||||
terminate_abnormal_dispatches_call_delete_test() ->
|
||||
State = new_call_test_state(#{
|
||||
recipients => [100, 200],
|
||||
voice_states => #{},
|
||||
ringing => [],
|
||||
initiator_ready => true
|
||||
}),
|
||||
?assertEqual(ok, call:terminate(killed, State)).
|
||||
|
||||
terminate_handoff_skips_cleanup_test() ->
|
||||
State = new_call_test_state(#{
|
||||
recipients => [100],
|
||||
voice_states => #{42 => #{<<"connection_id">> => <<"conn-42">>}},
|
||||
initiator_ready => true
|
||||
}),
|
||||
?assertEqual(ok, call:terminate({shutdown, handoff}, State)),
|
||||
?assertEqual(ok, call:terminate(handoff, State)).
|
||||
|
||||
terminate_normal_cleans_counts_test() ->
|
||||
State = new_call_test_state(#{
|
||||
recipients => [],
|
||||
voice_states => #{},
|
||||
initiator_ready => true
|
||||
}),
|
||||
?assertEqual(ok, call:terminate(normal, State)).
|
||||
|
||||
call_manager_cleanup_call_pid_cache_on_down_test() ->
|
||||
case ets:info(call_pid_cache) of
|
||||
undefined ->
|
||||
@@ -348,10 +264,6 @@ voice_count(CollectionKey, IdKey, Id) ->
|
||||
Entries
|
||||
).
|
||||
|
||||
has_pending_connection(Expected, Result) ->
|
||||
Keys = maps:keys(Expected),
|
||||
lists:any(fun(Connection) -> maps:with(Keys, Connection) =:= Expected end, Result).
|
||||
|
||||
leave_with_second_session_keeps_voice_state_test() ->
|
||||
UserId = 42,
|
||||
VoiceState = #{
|
||||
@@ -427,7 +339,7 @@ disconnect_user_removes_all_user_sessions_test() ->
|
||||
ok
|
||||
end,
|
||||
{ok, NewVoiceStates, NewSessions} = voice_disconnect_common:disconnect_user_if_in_channel(
|
||||
UserId, 1, VoiceStates, Sessions, CleanupFun
|
||||
UserId, 1, undefined, VoiceStates, Sessions, CleanupFun
|
||||
),
|
||||
?assertEqual(#{}, NewVoiceStates),
|
||||
?assertEqual([<<"session-other">>], maps:keys(NewSessions)),
|
||||
|
||||
Reference in new issue
Block a user