Skip to content

Commit

Permalink
Simplify case init conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Mar 8, 2024
1 parent dfe5530 commit 3d5ffe0
Showing 1 changed file with 28 additions and 50 deletions.
78 changes: 28 additions & 50 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -751,70 +751,48 @@ init_users(CaseName, Config) ->
escalus_fresh:create_users(Config, UserSpecs)
end.

fresh_users(C) when C =:= querying_for_all_messages_with_jid;
C =:= query_messages_by_ids;
C =:= simple_query_messages_by_ids;
C =:= server_returns_item_not_found_for_ids_filter_with_nonexistent_id;
C =:= offline_message;
C =:= pagination_simple_enforced;
C =:= range_archive_request_not_empty;
C =:= limit_archive_request;
C =:= metadata_archive_request ->
-define(requires_pm_archive(C),
C =:= querying_for_all_messages_with_jid;
C =:= query_messages_by_ids;
C =:= simple_query_messages_by_ids;
C =:= server_returns_item_not_found_for_ids_filter_with_nonexistent_id;
C =:= pagination_simple_enforced;
C =:= range_archive_request_not_empty;
C =:= limit_archive_request;
C =:= metadata_archive_request).

-define(requires_muc_archive(C),
C =:= muc_query_messages_by_ids;
C =:= muc_simple_query_messages_by_ids;
C =:= muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id;
C =:= muc_querying_for_all_messages;
C =:= muc_querying_for_all_messages_with_jid;
C =:= muc_metadata_archive_request).

fresh_users(C) when ?requires_pm_archive(C) ->
[{alice, 1}, {bob, 1}, {carol, 1}];
fresh_users(C) when C =:= archived;
C =:= muc_query_messages_by_ids;
C =:= muc_simple_query_messages_by_ids;
C =:= muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id;
C =:= muc_querying_for_all_messages;
C =:= muc_querying_for_all_messages_with_jid;
C =:= muc_archive_request;
C =:= muc_no_elements;
C =:= muc_only_stanzaid;
fresh_users(C) when C =:= offline_message;
C =:= archived;
C =:= no_elements;
C =:= only_stanzaid;
C =:= same_stanza_id;
C =:= muc_message_with_stanzaid;
C =:= retract_muc_message;
C =:= retract_muc_message_on_stanza_id;
C =:= retract_wrong_muc_message;
C =:= muc_multiple_devices;
C =:= muc_protected_message;
C =:= muc_deny_protected_room_access;
C =:= muc_allow_access_to_owner;
C =:= muc_sanitize_x_user_in_non_anon_rooms;
C =:= muc_delete_x_user_in_anon_rooms;
C =:= muc_show_x_user_to_moderators_in_anon_rooms;
C =:= muc_show_x_user_for_your_own_messages_in_anon_rooms;
C =:= metadata_archive_request_empty;
C =:= metadata_archive_request_one_message;
C =:= muc_metadata_archive_request;
C =:= muc_metadata_archive_request_empty;
C =:= muc_metadata_archive_request;
C =:= muc_text_search_request;
C =:= archive_chat_markers;
C =:= dont_archive_chat_markers ->
[{alice, 1}, {bob, 1}];
fresh_users(_C) ->
[].
fresh_users(C) ->
case lists:member(C, all_cases_with_room()) of
true -> [{alice, 1}, {bob, 1}];
false -> []
end.

init_archive(C, Config) when C =:= metrics_incremented_for_async_pools;
C =:= metric_incremented_when_store_message ->
clean_archives(Config);
init_archive(C, Config) when C =:= querying_for_all_messages_with_jid;
C =:= query_messages_by_ids;
C =:= simple_query_messages_by_ids;
C =:= server_returns_item_not_found_for_ids_filter_with_nonexistent_id;
C =:= pagination_simple_enforced;
C =:= range_archive_request_not_empty;
C =:= limit_archive_request;
C =:= metadata_archive_request ->
init_archive(C, Config) when ?requires_pm_archive(C) ->
bootstrap_archive(Config);
init_archive(C, Config) when C =:= muc_query_messages_by_ids;
C =:= muc_simple_query_messages_by_ids;
C =:= muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id;
C =:= muc_querying_for_all_messages;
C =:= muc_querying_for_all_messages_with_jid;
C =:= muc_metadata_archive_request ->
init_archive(C, Config) when ?requires_muc_archive(C) ->
muc_bootstrap_archive(start_alice_room(Config));
init_archive(_CaseName, Config) ->
Config.
Expand Down

0 comments on commit 3d5ffe0

Please sign in to comment.