From 8444bb4f4d234eaa50fe7046a2ad85c47e5c2dfa Mon Sep 17 00:00:00 2001 From: Brujo Benavides Date: Wed, 14 Oct 2020 16:00:36 +0200 Subject: [PATCH] [rebar3_format-0.5.0] Pin rebar3_format to its latest release (#25) --- rebar.config | 2 +- src/kinetic_config.erl | 2 +- src/kinetic_stream.erl | 6 ++-- test/kinetic_config_tests.erl | 12 +++---- test/kinetic_stream_tests.erl | 62 +++++++++++++---------------------- test/kinetic_tests.erl | 22 ++++++------- test/kinetic_utils_tests.erl | 6 ++-- 7 files changed, 45 insertions(+), 67 deletions(-) diff --git a/rebar.config b/rebar.config index db4e910..41e3a8f 100644 --- a/rebar.config +++ b/rebar.config @@ -54,7 +54,7 @@ {alias, [{test, [format, lint, xref, dialyzer, eunit, cover, edoc]}]}. {plugins, [ - rebar3_format, + {rebar3_format, "~> 0.5.0"}, rebar3_lint, rebar3_hex ]}. diff --git a/src/kinetic_config.erl b/src/kinetic_config.erl index 19d5ef0..de9ce54 100644 --- a/src/kinetic_config.erl +++ b/src/kinetic_config.erl @@ -119,7 +119,7 @@ new_args(Opts) -> %% env if set in kinetic app env; these will be used to create session tokens: case {proplists:get_value(aws_access_key_id, Opts), proplists:get_value(aws_secret_access_key, Opts)} - of + of {undefined, _} -> ok; {_, undefined} -> diff --git a/src/kinetic_stream.erl b/src/kinetic_stream.erl index d40e693..536f785 100644 --- a/src/kinetic_stream.erl +++ b/src/kinetic_stream.erl @@ -135,8 +135,8 @@ internal_flush(State = timeout = Timeout, retries = Retries}) -> PartitionKey = partition_key(State), - spawn_link(fun () -> - send_to_kinesis(StreamName, Buffer, PartitionKey, Timeout, Retries + 1) + spawn_link(fun() -> + send_to_kinesis(StreamName, Buffer, PartitionKey, Timeout, Retries + 1) end), increment_partition_num(State#kinetic_stream{buffer = <<"">>, buffer_size = 0}). @@ -164,7 +164,7 @@ send_to_kinesis(StreamName, Buffer, PartitionKey, Timeout, Retries) -> {<<"PartitionKey">>, PartitionKey}, {<<"StreamName">>, StreamName}], Timeout) - of + of {ok, _} -> {ok, done}; {error, {Code, Headers, RawBody}} -> diff --git a/test/kinetic_config_tests.erl b/test/kinetic_config_tests.erl index ae87077..569db03 100644 --- a/test/kinetic_config_tests.erl +++ b/test/kinetic_config_tests.erl @@ -13,13 +13,11 @@ test_setup() -> meck:new(timer, [unstick, passthrough]), meck:expect(timer, apply_interval, - fun (Interval, M, F, [Opts]) -> - case proplists:get_value(should_err, Opts) of - true -> - {error, broken}; - _ -> - meck:passthrough([Interval, M, F, [Opts]]) - end + fun(Interval, M, F, [Opts]) -> + case proplists:get_value(should_err, Opts) of + true -> {error, broken}; + _ -> meck:passthrough([Interval, M, F, [Opts]]) + end end). test_teardown(_) -> diff --git a/test/kinetic_stream_tests.erl b/test/kinetic_stream_tests.erl index 754ca13..6703929 100644 --- a/test/kinetic_stream_tests.erl +++ b/test/kinetic_stream_tests.erl @@ -11,41 +11,26 @@ test_setup() -> meck:new(kinetic, [passthrough]), meck:expect(kinetic, put_record, - fun (Payload, Pid) -> - case Pid of - Pid when is_pid(Pid) -> - Pid ! done; - _ -> - ok - end, - case proplists:get_value(<<"PartitionKey">>, Payload) of - <<"otherstuff">> -> - {error, {400, headers, <<"{\"__type\": \"OtherStuff\"}">>}}; - <<"throughput">> -> - {error, - {400, - headers, - <<"{\"__type\": \"ProvisionedThroughputExceededException\"}">>}}; - _ -> - {ok, done} - end + fun(Payload, Pid) -> + case Pid of + Pid when is_pid(Pid) -> Pid ! done; + _ -> ok + end, + case proplists:get_value(<<"PartitionKey">>, Payload) of + <<"otherstuff">> -> + {error, {400, headers, <<"{\"__type\": \"OtherStuff\"}">>}}; + <<"throughput">> -> + {error, + {400, + headers, + <<"{\"__type\": \"ProvisionedThroughputExceededException\"}">>}}; + _ -> {ok, done} + end end), meck:new(timer, [unstick, passthrough]), - meck:expect(timer, - send_after, - fun (1000, _pid, flush) -> - {ok, tref} - end), - meck:expect(timer, - sleep, - fun (1000) -> - ok - end), - meck:expect(timer, - cancel, - fun (tref) -> - ok - end). + meck:expect(timer, send_after, fun(1000, _pid, flush) -> {ok, tref} end), + meck:expect(timer, sleep, fun(1000) -> ok end), + meck:expect(timer, cancel, fun(tref) -> ok end). test_teardown(_) -> ets:delete(?KINETIC_STREAM), @@ -73,10 +58,7 @@ test_get_stream() -> Pid = kinetic_stream:get_stream(<<"mystream">>, {<<"whatever">>}), ets:delete(?KINETIC_STREAM, <<"mystream">>), - ChildPid = - spawn(fun () -> - Pid ! done - end), + ChildPid = spawn(fun() -> Pid ! done end), ok = receive done -> @@ -84,7 +66,7 @@ test_get_stream() -> _ -> bad after 1000 -> - bad + bad end, ets:insert_new(?KINETIC_STREAM, {<<"mystream">>, ChildPid}), pid = kinetic_stream:get_stream(<<"mystream">>, {<<"whatever">>}). @@ -134,7 +116,7 @@ test_functionality() -> {<<"StreamName">>, S}], receive after 100 -> - ok + ok end, true = meck:called(kinetic, put_record, [Payload2, Pid]), kinetic_stream:flush(S, {P}), @@ -175,5 +157,5 @@ wait_for_flush() -> _ -> bad after 1000 -> - bad + bad end. diff --git a/test/kinetic_tests.erl b/test/kinetic_tests.erl index 5fd8cd6..10a59ec 100644 --- a/test/kinetic_tests.erl +++ b/test/kinetic_tests.erl @@ -66,9 +66,9 @@ sample_arglists(Payload) -> [Payload, [{region, "us-east-1"}, {timeout, 12345}]]]. test_normal_functions() -> - lists:foreach(fun (F) -> - [{ok, [{<<"hello">>, <<"world">>}]} = erlang:apply(kinetic, F, Args) - || Args <- sample_arglists([])] + lists:foreach(fun(F) -> + [{ok, [{<<"hello">>, <<"world">>}]} = erlang:apply(kinetic, F, Args) + || Args <- sample_arglists([])] end, [create_stream, delete_stream, @@ -80,9 +80,7 @@ test_normal_functions() -> put_record, split_shard]), - lists:foreach(fun (F) -> - {error, _} = erlang:apply(kinetic, F, [{whatever}]) - end, + lists:foreach(fun(F) -> {error, _} = erlang:apply(kinetic, F, [{whatever}]) end, [create_stream, delete_stream, describe_stream, @@ -98,9 +96,9 @@ test_error_functions() -> kinetic_config:update_data([{aws_access_key_id, "whatever"}, {aws_secret_access_key, "secret"}, {lhttpc_opts, error}]), - lists:foreach(fun (F) -> - [{error, {400, headers, body}} = erlang:apply(kinetic, F, Args) - || Args <- sample_arglists([])] + lists:foreach(fun(F) -> + [{error, {400, headers, body}} = erlang:apply(kinetic, F, Args) + || Args <- sample_arglists([])] end, [create_stream, delete_stream, @@ -112,9 +110,9 @@ test_error_functions() -> put_record, split_shard]), ets:delete_all_objects(?KINETIC_DATA), - lists:foreach(fun (F) -> - [{error, missing_args} = erlang:apply(kinetic, F, Args) - || Args <- sample_arglists([])] + lists:foreach(fun(F) -> + [{error, missing_args} = erlang:apply(kinetic, F, Args) + || Args <- sample_arglists([])] end, [create_stream, delete_stream, diff --git a/test/kinetic_utils_tests.erl b/test/kinetic_utils_tests.erl index e745012..00896a5 100644 --- a/test/kinetic_utils_tests.erl +++ b/test/kinetic_utils_tests.erl @@ -23,8 +23,8 @@ test_endpoint() -> Service = "kinesis", Regions = ["us-east-1", "us-west-1", "us-west-2", "eu-west-1", "ap-northeast-1", "ap-southeast-1"], - lists:foreach(fun (Region) -> - Url = Service ++ "." ++ Region ++ ".amazonaws.com", - Url = kinetic_utils:endpoint(Service, Region) + lists:foreach(fun(Region) -> + Url = Service ++ "." ++ Region ++ ".amazonaws.com", + Url = kinetic_utils:endpoint(Service, Region) end, Regions).