<commit_before>%%%-------------------------------------------------------------------
%% @copyright Heroku, 2013
%% @author <NAME> <<EMAIL>>
%% @doc CommonTest test suite for logplex_token
%% @end
%%%-------------------------------------------------------------------

-module(logplex_token_SUITE).
-include_lib("common_test/include/ct.hrl").
-compile(export_all).

%%%%%%%%%%%%%%%%%%%%
%%% Tests to run %%%
%%%%%%%%%%%%%%%%%%%%
%% Specific test cases or groups to run. The test case is named as
%% a single atom.

all() ->
    [lookup_by_channel].

%%%%%%%%%%%%%%%%%%%%%%
%%% Setup/Teardown %%%
%%%%%%%%%%%%%%%%%%%%%%
%% Runs once at the beginning of the suite. The process is different
%% from the one the case will run in.
init_per_suite(Config) ->
    Config.

%% Runs once at the end of the suite. The process is different
%% from the one the case will run in.
end_per_suite(Config) ->
    Config.

%% Runs before the test case. Runs in the same process.
init_per_testcase(lookup_by_channel, Config) ->
    logplex_db:start_link(),
    [{chan, 1} | Config];
init_per_testcase(_CaseName, Config) ->
    Config.

%% Runs after the test case. Runs in the same process.
end_per_testcase(_CaseName, Config) ->
    Config.

%%%%%%%%%%%%%
%%% TESTS %%%
%%%%%%%%%%%%%

lookup_by_channel(Config) ->
    Chan = ?config(chan, Config),
    Tokens = [ logplex_token:new(Chan, list_to_binary(Name))
               || Name <- ["heroku", "app", "postgres", "bob"]],
    [] = logplex_token:lookup_by_channel(Chan),
    [ logplex_token:cache(Token)
      || Token <- Tokens ],
    true = lists:sort(Tokens) =:=
        lists:sort(logplex_token:lookup_by_channel(Chan)).
<commit_msg>Test delete_by_channel as well.<commit_after>%%%-------------------------------------------------------------------
%% @copyright Heroku, 2013
%% @author <NAME> <<EMAIL>.nz>
%% @doc CommonTest test suite for logplex_token
%% @end
%%%-------------------------------------------------------------------

-module(logplex_token_SUITE).
-include_lib("common_test/include/ct.hrl").
-compile(export_all).

%%%%%%%%%%%%%%%%%%%%
%%% Tests to run %%%
%%%%%%%%%%%%%%%%%%%%
%% Specific test cases or groups to run. The test case is named as
%% a single atom.

all() ->
    [by_channel].

%%%%%%%%%%%%%%%%%%%%%%
%%% Setup/Teardown %%%
%%%%%%%%%%%%%%%%%%%%%%
%% Runs once at the beginning of the suite. The process is different
%% from the one the case will run in.
init_per_suite(Config) ->
    Config.

%% Runs once at the end of the suite. The process is different
%% from the one the case will run in.
end_per_suite(Config) ->
    Config.

%% Runs before the test case. Runs in the same process.
init_per_testcase(by_channel, Config) ->
    logplex_db:start_link(),
    [{chan, 1} | Config];
init_per_testcase(_CaseName, Config) ->
    Config.

%% Runs after the test case. Runs in the same process.
end_per_testcase(_CaseName, Config) ->
    Config.

%%%%%%%%%%%%%
%%% TESTS %%%
%%%%%%%%%%%%%

by_channel(Config) ->
    Chan = ?config(chan, Config),
    Tokens = [ logplex_token:new(Chan, list_to_binary(Name))
               || Name <- ["heroku", "app", "postgres", "bob"]],
    [] = logplex_token:lookup_by_channel(Chan),
    [ logplex_token:cache(Token)
      || Token <- Tokens ],
    true = lists:sort(Tokens) =:=
        lists:sort(logplex_token:lookup_by_channel(Chan)),
    logplex_token:delete_by_channel(Chan),
    [] = logplex_token:lookup_by_channel(Chan).

{'fraction_non_alphanumeric': 0.26450860309128027, 'fraction_numerical': 0.0029163021289005542, 'mean_word_length': 2.853932584269663, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3923991', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1033, 'n_words': 275}