Skip to content

Commit

Permalink
[rebar3_format-0.5.0] Pin rebar3_format to its latest release (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brujo Benavides authored Oct 14, 2020
1 parent b2fb70f commit 8444bb4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 67 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
]}.
Expand Down
2 changes: 1 addition & 1 deletion src/kinetic_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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} ->
Expand Down
6 changes: 3 additions & 3 deletions src/kinetic_stream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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}).

Expand Down Expand Up @@ -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}} ->
Expand Down
12 changes: 5 additions & 7 deletions test/kinetic_config_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) ->
Expand Down
62 changes: 22 additions & 40 deletions test/kinetic_stream_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -73,18 +58,15 @@ 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 ->
ok;
_ ->
bad
after 1000 ->
bad
bad
end,
ets:insert_new(?KINETIC_STREAM, {<<"mystream">>, ChildPid}),
pid = kinetic_stream:get_stream(<<"mystream">>, {<<"whatever">>}).
Expand Down Expand Up @@ -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}),
Expand Down Expand Up @@ -175,5 +157,5 @@ wait_for_flush() ->
_ ->
bad
after 1000 ->
bad
bad
end.
22 changes: 10 additions & 12 deletions test/kinetic_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions test/kinetic_utils_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 8444bb4

Please sign in to comment.