<commit_before>-module(itest).

-exports([setup_env/0, basic_test_/0]).

-include_lib("eunit/include/eunit.hrl").
-include("sqerl.hrl").

-record(user, {id, first_name, last_name}).

-define(ARGS, [host, port, db, db_type]).
-define(GET_ARG(Name, Args), proplists:get_value(Name, Args)).
-define(NAMES, [["Kevin", "Smith"],
                ["Mark", "Anderson"],
                ["Chris", "Maier"]]).

get_dbinfo() ->
    F = fun(port) ->
                {ok, [[Port]]} = init:get_argument(port),
                {port, list_to_integer(Port)};
           (db_type) ->
                {ok, [[Type]]} = init:get_argument(db_type),
                {db_type, list_to_atom(Type)};
           (Name) ->
                {ok, [[Value]]} = init:get_argument(Name),
                {Name, Value} end,
    [F(Arg) || Arg <- ?ARGS].

setup_env() ->
    Info = get_dbinfo(),
    Type = ?GET_ARG(db_type, Info),
    ok = application:set_env(sqerl, db_host, ?GET_ARG(host, Info)),
    ok = application:set_env(sqerl, db_port, ?GET_ARG(port, Info)),
    ok = application:set_env(sqerl, db_user, "itest"),
    ok = application:set_env(sqerl, db_pass, "<PASSWORD>"),
    ok = application:set_env(sqerl, db_name, ?GET_ARG(db, Info)),
    ok = application:set_env(sqerl, db_pool_size, 3),
    ok = application:set_env(sqerl, db_type, Type),
    ok = application:set_env(sqerl, db_prepared_statements, "itest/statements_pgsql.conf"),
    application:start(crypto),
    application:start(emysql),
    application:start(public_key),
    application:start(ssl),
    application:start(epgsql).   

basic_test_() ->
    setup_env(),
    {foreach,
     fun() -> error_logger:tty(false) end,
     fun(_) -> error_logger:tty(true) end,
     [
      {<<"Insert operations">>,
       fun insert_data/0},
      {<<"Select operations">>,
       fun select_data/0},
      {<<"Select w/record xform operations">>,<commit_msg>Restore start of applicaton sqerl.<commit_after>-module(itest).

-exports([setup_env/0, basic_test_/0]).

-include_lib("eunit/include/eunit.hrl").
-include("sqerl.hrl").

-record(user, {id, first_name, last_name}).

-define(ARGS, [host, port, db, db_type]).
-define(GET_ARG(Name, Args), proplists:get_value(Name, Args)).
-define(NAMES, [["Kevin", "Smith"],
                ["Mark", "Anderson"],
                ["Chris", "Maier"]]).

get_dbinfo() ->
    F = fun(port) ->
                {ok, [[Port]]} = init:get_argument(port),
                {port, list_to_integer(Port)};
           (db_type) ->
                {ok, [[Type]]} = init:get_argument(db_type),
                {db_type, list_to_atom(Type)};
           (Name) ->
                {ok, [[Value]]} = init:get_argument(Name),
                {Name, Value} end,
    [F(Arg) || Arg <- ?ARGS].

setup_env() ->
    Info = get_dbinfo(),
    Type = ?GET_ARG(db_type, Info),
    ok = application:set_env(sqerl, db_host, ?GET_ARG(host, Info)),
    ok = application:set_env(sqerl, db_port, ?GET_ARG(port, Info)),
    ok = application:set_env(sqerl, db_user, "itest"),
    ok = application:set_env(sqerl, db_pass, "itest"),
    ok = application:set_env(sqerl, db_name, ?GET_ARG(db, Info)),
    ok = application:set_env(sqerl, db_pool_size, 3),
    ok = application:set_env(sqerl, db_type, Type),
    ok = application:set_env(sqerl, db_prepared_statements, "itest/statements_pgsql.conf"),
    application:start(crypto),
    application:start(emysql),
    application:start(public_key),
    application:start(ssl),
    application:start(epgsql).   

basic_test_() ->
    setup_env(),
    application:start(sqerl),
    {foreach,
     fun() -> error_logger:tty(false) end,
     fun(_) -> error_logger:tty(true) end,
     [
      {<<"Insert operations">>,
       fun insert_data/0},
      {<<"Select operations">>,
       fun select_data/0},
      {<<"Select w/record xform operations">>,
{'fraction_non_alphanumeric': 0.17913179916317992, 'fraction_numerical': 0.002615062761506276, 'mean_word_length': 3.09967845659164, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 32, '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': '6367852', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1345, 'n_words': 236}