From fc5b34451e021b184911f4adbf2d76913a079c82 Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Thu, 3 Oct 2024 20:16:29 +0200 Subject: [PATCH 1/6] Add --quiet to the pack command call --- src/rebar3_grisp_io_upload.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rebar3_grisp_io_upload.erl b/src/rebar3_grisp_io_upload.erl index 466c478..306baff 100644 --- a/src/rebar3_grisp_io_upload.erl +++ b/src/rebar3_grisp_io_upload.erl @@ -114,9 +114,9 @@ options() -> [ try_pack_command(RState, Force) -> Args = case Force of true -> - ["--force"]; + ["--quiet", "--force"]; false -> - [] + ["--quiet"] end, case rebar3_grisp_io_utils:grisp_pack(RState, Args) of {error, Reason} -> From 9dfab627e981ba5ac963af8b45514f4ef6e95b3e Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Thu, 3 Oct 2024 20:18:53 +0200 Subject: [PATCH 2/6] Remove catch-all clauses that hides the stacktrace of unexpected errors --- src/rebar3_grisp_io_auth.erl | 9 +-------- src/rebar3_grisp_io_deploy.erl | 9 +-------- src/rebar3_grisp_io_upload.erl | 9 +-------- src/rebar3_grisp_io_validate.erl | 9 +-------- 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/rebar3_grisp_io_auth.erl b/src/rebar3_grisp_io_auth.erl index 046cce0..3d35254 100644 --- a/src/rebar3_grisp_io_auth.erl +++ b/src/rebar3_grisp_io_auth.erl @@ -64,14 +64,7 @@ do(RState) -> throw:forbidden -> abort("Error: No permission to perform this operation"); throw:not_matching -> - abort("Error: The 2 local password entries don't match"); - error:E:S -> - case lists:member(test, rebar_state:current_profiles(RState)) of - true -> - abort("Unexpected error: ~p -> ~p ~n", [E, S]); - false -> - abort("Unexpected error: ~p ~n", [E]) - end + abort("Error: The 2 local password entries don't match") end. -spec format_error(any()) -> iolist(). diff --git a/src/rebar3_grisp_io_deploy.erl b/src/rebar3_grisp_io_deploy.erl index 7236f21..a136b7b 100644 --- a/src/rebar3_grisp_io_deploy.erl +++ b/src/rebar3_grisp_io_deploy.erl @@ -70,14 +70,7 @@ do(RState) -> abort("Error: No permission to perform this operation"); throw:package_does_not_exist -> abort("Error: The package doesn't exists. Use the upload command" ++ - " first to upload an update package to grisp.io"); - error:E:S -> - case lists:member(test, rebar_state:current_profiles(RState)) of - true -> - abort("Unexpected error: ~p -> ~p ~n", [E, S]); - false -> - abort("Unexpected error: ~p ~n", [E]) - end + " first to upload an update package to grisp.io") end. -spec format_error(any()) -> iolist(). diff --git a/src/rebar3_grisp_io_upload.erl b/src/rebar3_grisp_io_upload.erl index 306baff..edaa87f 100644 --- a/src/rebar3_grisp_io_upload.erl +++ b/src/rebar3_grisp_io_upload.erl @@ -87,14 +87,7 @@ do(RState) -> abort("Error: A package has already been uploaded for " ++ "the same release. Use -f or --force to force the upload"); throw:package_too_big -> - abort("Package size is too big"); - error:E:S -> - case lists:member(test, rebar_state:current_profiles(RState)) of - true -> - abort("Unexpected error: ~p -> ~p ~n", [E, S]); - false -> - abort("Unexpected error: ~p ~n", [E]) - end + abort("Package size is too big") end. -spec format_error(any()) -> iolist(). diff --git a/src/rebar3_grisp_io_validate.erl b/src/rebar3_grisp_io_validate.erl index c92a631..549dbdd 100644 --- a/src/rebar3_grisp_io_validate.erl +++ b/src/rebar3_grisp_io_validate.erl @@ -75,14 +75,7 @@ do(RState) -> throw:forbidden -> abort("Error: No permission to perform this operation"); throw:device_does_not_exist-> - abort("Error: The given board doesn't exists or isn't linked"); - error:E:S -> - case lists:member(test, rebar_state:current_profiles(RState)) of - true -> - abort("Unexpected error: ~p -> ~p ~n", [E, S]); - false -> - abort("Unexpected error: ~p ~n", [E]) - end + abort("Error: The given board doesn't exists or isn't linked") end. -spec format_error(any()) -> iolist(). From 067a3c731aab2df8bab65336b6544337b975a8dc Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Thu, 3 Oct 2024 20:15:51 +0200 Subject: [PATCH 3/6] Use rebar3:run/1 to call sub-commands --- src/rebar3_grisp_io_utils.erl | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/rebar3_grisp_io_utils.erl b/src/rebar3_grisp_io_utils.erl index 4420490..8b356b8 100644 --- a/src/rebar3_grisp_io_utils.erl +++ b/src/rebar3_grisp_io_utils.erl @@ -7,17 +7,9 @@ %--- API ----------------------------------------------------------------------- grisp_pack(RState, Args) -> - % TODO remove workaround for profiles - OriginalProfile = rebar_state:current_profiles(RState), - - RState1 = rebar_state:current_profiles(RState, [default]), - - case rebar_command(RState1, grisp, pack, Args) of - {error, _} = Error -> - Error; - {ok, RS} -> - RS1 = rebar_state:current_profiles(RS, OriginalProfile), - {ok, RS1} + case rebar3:run(["grisp", "pack" | Args]) of + {error, _Reason} = Error -> Error; + {ok, _} -> {ok, RState} end. -spec expected_package_name(rebar_state:t()) -> list(). @@ -29,27 +21,6 @@ expected_package_name(RState) -> %--- Internals ----------------------------------------------------------------- -rebar_command(RState, Namespace, Command, Args) -> - % Backup current command state - OriginalNamespace = rebar_state:namespace(RState), - OriginalArgs = rebar_state:command_args(RState), - OriginalParsedArgs = rebar_state:command_parsed_args(RState), - - % Args are parsed by rebar_core - RebarState2 = rebar_state:namespace(RState, Namespace), - RebarState3 = rebar_state:command_args(RebarState2, Args), - - case rebar_core:process_command(RebarState3, Command) of - {error, _Reason} = Error -> - Error; - {ok, RS} -> - % Restore current command state - RS2 = rebar_state:namespace(RS, OriginalNamespace), - RS3 = rebar_state:command_args(RS2, OriginalArgs), - RS4 = rebar_state:command_parsed_args(RS3, OriginalParsedArgs), - {ok, RS4} - end. - release(RState) -> Relx = rebar_state:get(RState, relx, []), case lists:keyfind(release, 1, Relx) of From ceaf524991959194cb9cb05f78974246298b34e3 Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Fri, 4 Oct 2024 12:14:28 +0200 Subject: [PATCH 4/6] Reuse rebar3_grisp utility function and uniformize command parameters * Add relname and relvsn parameters to upload command. * Use rebar3_grisp utility function to get the package name and path. * Add refresh parameter to upload comand and remove no-pack to follow the same pattern as rebar3_grisp. * Stream the package file instead of loading it in memory. --- src/rebar3_grisp_io_api.erl | 30 +++++---- src/rebar3_grisp_io_deploy.erl | 19 ++++-- src/rebar3_grisp_io_io.erl | 2 +- src/rebar3_grisp_io_upload.erl | 114 ++++++++++++++++++--------------- src/rebar3_grisp_io_utils.erl | 47 +++++--------- 5 files changed, 111 insertions(+), 101 deletions(-) diff --git a/src/rebar3_grisp_io_api.erl b/src/rebar3_grisp_io_api.erl index 3ded4db..a1cd901 100644 --- a/src/rebar3_grisp_io_api.erl +++ b/src/rebar3_grisp_io_api.erl @@ -41,29 +41,31 @@ auth(RState, Username, Password) -> %% @doc Performs a PUT request tp /grisp-manager/api/update-package/PackageName %% @param Token is the clear token of the user -%% @param PackageName must have the following format "platform.appname.x.y.z.tar -%% @param PackageBin is the content of the package +%% @param PackageName must have the following format +%% platform.appname.x.y.z.[profilename[+profilename]].tar +%% @param PackagePath is the path to the package file to upload %% @param Force indicates if the PUT request should overwrite %% the remote files if they exist --spec update_package(RState, Token, PackageName, PackageBin, Force) -> Res when +-spec update_package(RState, Token, PackageName, PackagePath, Force) -> Res + when RState :: rebar_state:t(), Token :: rebar3_grisp_io_config:clear_token(), - PackageName :: string(), - PackageBin :: binary(), + PackageName :: binary(), + PackagePath :: binary(), Force :: boolean(), Res :: ok | no_return(). -update_package(RState, Token, PackageName, PackageBin, Force) -> +update_package(RState, Token, PackageName, PackagePath, Force) -> BaseUrl = base_url(RState), URI = list_to_binary("/grisp-manager/api/update-package/" ++ PackageName), Url = <>, - BinSize = byte_size(PackageBin), + BinSize = filelib:file_size(PackagePath), + Etag = <<"\"", PackageName/binary, "\"">>, Headers = [{<<"authorization">>, bearer_token(Token)}, {<<"content-type">>, <<"application/octet-stream">>}, {<<"content-length">>, integer_to_binary(BinSize)}] - ++ if_none_match(Force, "\"" ++ PackageName ++ "\""), + ++ if_none_match(Force, Etag), Options = insecure_option(RState), - - case hackney:request(put, Url, Headers, PackageBin, Options) of + case hackney:request(put, Url, Headers, {file, PackagePath}, Options) of {ok, 201, _, _} -> ok; {ok, 204, _, _} -> @@ -97,7 +99,7 @@ update_package(RState, Token, PackageName, PackageBin, Force) -> Res :: ok | no_return(). deploy_update(RState, Token, PackageName, Device) -> BaseUrl = base_url(RState), - URI = list_to_binary( "/grisp-manager/api/deploy-update/" ++ PackageName), + URI = list_to_binary("/grisp-manager/api/deploy-update/" ++ PackageName), QS = <<"device=", (integer_to_binary(Device))/binary>>, Url = hackney_url:make_url(BaseUrl, URI, QS), Headers = [{<<"authorization">>, bearer_token(Token)}, @@ -114,7 +116,7 @@ deploy_update(RState, Token, PackageName, Device) -> {ok, 401, _, _} -> throw(wrong_credentials); {ok, 404, _, _} -> - throw(package_does_not_exist); + throw({package_does_not_exist, PackageName}); Other -> error({error, Other}) end. @@ -181,9 +183,9 @@ insecure_option(RState) -> %% The Etag format must be: <<"\"...\"">> -spec if_none_match(Force, Etag) -> Result when Force :: boolean(), - Etag :: string(), + Etag :: binary(), Result :: [{binary(), binary()}]. if_none_match(true, _) -> []; if_none_match(false, Etag) -> - [{<<"if-none-match">>, list_to_binary(Etag)}]. + [{<<"if-none-match">>, Etag}]. diff --git a/src/rebar3_grisp_io_deploy.erl b/src/rebar3_grisp_io_deploy.erl index a136b7b..1542a00 100644 --- a/src/rebar3_grisp_io_deploy.erl +++ b/src/rebar3_grisp_io_deploy.erl @@ -42,8 +42,14 @@ do(RState) -> {ok, _} = application:ensure_all_started(rebar3_grisp_io), try {Args, _} = rebar_state:command_parsed_args(RState), + RelNameArg = proplists:get_value(relname, Args, undefined), + RelVsnArg = proplists:get_value(relvsn, Args, undefined), Device = try_get_device_serial(Args), - CurrentRelease = rebar3_grisp_io_utils:expected_package_name(RState), + + {RelName, RelVsn} + = rebar3_grisp_util:select_release(RState, RelNameArg, RelVsnArg), + CurrentRelease = binary_to_list( + rebar3_grisp_util:update_file_name(RState, RelName, RelVsn)), PackageName = proplists:get_value(package, Args, CurrentRelease), Config = rebar3_grisp_io_config:read_config(RState), @@ -68,9 +74,10 @@ do(RState) -> abort("Error: Wrong credentials"); throw:forbidden -> abort("Error: No permission to perform this operation"); - throw:package_does_not_exist -> - abort("Error: The package doesn't exists. Use the upload command" ++ - " first to upload an update package to grisp.io") + throw:{package_does_not_exist, Name} -> + abort("Error: The package ~s doesn't exists. Use the upload " ++ + "command first to upload an update package to grisp.io", + [Name]) end. -spec format_error(any()) -> iolist(). @@ -80,6 +87,10 @@ format_error(Reason) -> %--- Internals ----------------------------------------------------------------- options() -> [ + {relname, $n, "relname", string, + "Specify the name for the release to deploy"}, + {relvsn, $v, "relvsn", string, + "Specify the version of the release to deploy"}, {device, $d, "device", integer, "The serial number of the GRiSP board"}, {package, $p, "package", string, "The name of the package that will be deployed"} diff --git a/src/rebar3_grisp_io_io.erl b/src/rebar3_grisp_io_io.erl index 37b49f7..45ec3cf 100644 --- a/src/rebar3_grisp_io_io.erl +++ b/src/rebar3_grisp_io_io.erl @@ -45,7 +45,7 @@ success(Msg) -> success(Msg, []). success(Msg, Args) -> Text = io_lib:format(Msg, Args), - rebar_api:console(color(40, Text), Args). + rebar_api:console(color(40, Text), []). %--- Internals ----------------------------------------------------------------- diff --git a/src/rebar3_grisp_io_upload.erl b/src/rebar3_grisp_io_upload.erl index edaa87f..83665bc 100644 --- a/src/rebar3_grisp_io_upload.erl +++ b/src/rebar3_grisp_io_upload.erl @@ -17,6 +17,12 @@ success/1, success/2]). + +%--- MACROS -------------------------------------------------------------------- + +-define(MAX_DDOT, 2). + + %--- API ----------------------------------------------------------------------- -spec init(rebar_state:t()) -> {ok, rebar_state:t()}. @@ -39,9 +45,14 @@ init(State) -> do(RState) -> {ok, _} = application:ensure_all_started(rebar3_grisp_io), try - {Args, _} = rebar_state:command_parsed_args(RState), + {Args, ExtraArgs} = rebar_state:command_parsed_args(RState), + RelNameArg = proplists:get_value(relname, Args, undefined), + RelVsnArg = proplists:get_value(relvsn, Args, undefined), + {RelName, RelVsn} + = rebar3_grisp_util:select_release(RState, RelNameArg, RelVsnArg), + Force = proplists:get_value(force, Args), - NoPack = proplists:get_value(no_pack, Args), + Refresh = proplists:get_value(refresh, Args), Config = rebar3_grisp_io_config:read_config(RState), EncryptedToken = maps:get(encrypted_token, Config), @@ -49,27 +60,16 @@ do(RState) -> Token = rebar3_grisp_io_config:try_decrypt_token(Password, EncryptedToken), - RState1 = case NoPack of - false -> - try_pack_command(RState, Force); - true -> - RState - end, + case get_package(RState, Refresh, RelName, RelVsn, ExtraArgs) of + {error, _Reason} = Error -> Error; + {ok, PackageName, PackagePath, RState2} -> + rebar3_grisp_io_api:update_package(RState2, Token, PackageName, + PackagePath, Force), + success("Package ~s succesfully uploaded to grisp.io", + [PackageName]), + {ok, RState2} + end - ProjectDir = rebar_state:dir(RState), - PackageName = rebar3_grisp_io_utils:expected_package_name(RState), - {ok, PackageBin} = try_get_package_bin(ProjectDir, PackageName), - - rebar3_grisp_io_api:update_package(RState1, - Token, - PackageName, - PackageBin, - Force), - - success("Package " ++ PackageName ++ - " succesfully uploaded to grisp.io"), - - {ok, RState1} catch throw:enoent -> abort("No configuration available." ++ @@ -86,6 +86,9 @@ do(RState) -> throw:package_already_exists -> abort("Error: A package has already been uploaded for " ++ "the same release. Use -f or --force to force the upload"); + throw:{package_not_found, Name} -> + abort("Error: Package file ~s not found", + [grisp_tools_util:maybe_relative(Name, ?MAX_DDOT)]); throw:package_too_big -> abort("Package size is too big") end. @@ -95,38 +98,47 @@ format_error(Reason) -> io_lib:format("~p", [Reason]). %--- Internals ----------------------------------------------------------------- + options() -> [ + {relname, $n, "relname", string, + "Specify the name for the release that will be uploaded"}, + {relvsn, $v, "relvsn", string, + "Specify the version of the release"}, {force, $f, "force", {boolean, false}, - "Force overwriting of the files both locally and remotely"}, - {no_pack, $n, "no-pack", {boolean, false}, - "Do not run the pack command on " ++ - "the current project before uploading"} + "Force overwriting of the package remotely"}, + {refresh, $r, "refresh", {boolean, false}, + "Force software package building even if it already exists"} ]. --spec try_pack_command(rebar_state:t(), boolean()) -> rebar_state:t(). -try_pack_command(RState, Force) -> - Args = case Force of - true -> - ["--quiet", "--force"]; - false -> - ["--quiet"] - end, - case rebar3_grisp_io_utils:grisp_pack(RState, Args) of - {error, Reason} -> - error(Reason); - {ok, NewRState} -> - NewRState +-spec get_package(rebar_state:t(), boolean(), binary(), binary(), [binary()]) + -> {ok, rebar_state:t()} | {error, term()}. +get_package(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> + PackageName = rebar3_grisp_util:update_file_name(RState, RelName, RelVsn), + PackagePath = rebar3_grisp_util:update_file_path(RState, RelName, RelVsn), + case filelib:is_file(PackagePath) of + true when Refresh =:= false -> + RelPath = grisp_tools_util:maybe_relative(PackagePath, ?MAX_DDOT), + console("* Using existing package: ~s", [RelPath]), + {ok, PackageName, PackagePath, RState}; + _ -> + console("* Building software package...", []), + case build_package(RState, Refresh, RelName, + RelVsn, ExtraRelArgs) of + {ok, RState2} -> {ok, PackageName, PackagePath, RState2}; + {error, _Reason} = Error -> Error + end end. --spec try_get_package_bin(ProjectDir, PackageName) -> Result when - ProjectDir :: string(), - PackageName :: string(), - Result :: {ok, binary()} | {error, term()}. -try_get_package_bin(ProjectDir, PackageName) -> - Path = filename:join([ProjectDir, "_grisp/update/", PackageName]), - case filelib:is_file(Path) of - false -> - error(package_not_found); - true -> - file:read_file(Path) - end. +-spec build_package(rebar_state:t(), boolean(), binary(), binary(), [binary()]) + -> {ok, rebar_state:t()} | {error, term()}. +build_package(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> + Args = [ + "--force", + "--quiet", + "--relname", atom_to_list(RelName), + "--relvsn", RelVsn + ] ++ case Refresh of + true -> ["--refresh"]; + false -> [] + end, + rebar3_grisp_io_utils:grisp_pack(RState, Args, ExtraRelArgs). diff --git a/src/rebar3_grisp_io_utils.erl b/src/rebar3_grisp_io_utils.erl index 8b356b8..5796bcd 100644 --- a/src/rebar3_grisp_io_utils.erl +++ b/src/rebar3_grisp_io_utils.erl @@ -1,40 +1,25 @@ -module(rebar3_grisp_io_utils). % api --export([grisp_pack/2]). --export([expected_package_name/1]). +-export([grisp_pack/3]). %--- API ----------------------------------------------------------------------- -grisp_pack(RState, Args) -> - case rebar3:run(["grisp", "pack" | Args]) of +grisp_pack(RState, Args, ExtraRelArgs) -> + RebarParams = [ + "as" + ] ++ [ + lists:join(",", [atom_to_list(P) + || P <- rebar_state:current_profiles(RState), + P =/= test]) + ] ++ [ + "grisp", + "pack" + ] ++ Args ++ case ExtraRelArgs of + [_ | _] -> ["--" | ExtraRelArgs]; + _ -> [] + end, + case rebar3:run(RebarParams) of {error, _Reason} = Error -> Error; {ok, _} -> {ok, RState} end. - --spec expected_package_name(rebar_state:t()) -> list(). -expected_package_name(RState) -> - {AppName, Version} = release(RState), - Platform = platform(RState), - Elems = [atom_to_list(Platform), atom_to_list(AppName), Version, "tar"], - lists:flatten(lists:join(".", Elems)). - -%--- Internals ----------------------------------------------------------------- - -release(RState) -> - Relx = rebar_state:get(RState, relx, []), - case lists:keyfind(release, 1, Relx) of - false -> - error(release_not_found); - {release, Rel, _} -> - Rel - end. - -platform(RState) -> - GRiSP = rebar_state:get(RState, grisp, []), - case lists:keyfind(platform, 1, GRiSP) of - false -> - grisp2; - {platform, Platform} -> - Platform - end. From 564f9c3068a386017c059e5d3875641169311d75 Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Mon, 7 Oct 2024 11:30:12 +0200 Subject: [PATCH 5/6] Fix dialyzer warnings --- src/rebar3_grisp_io_upload.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rebar3_grisp_io_upload.erl b/src/rebar3_grisp_io_upload.erl index 83665bc..8a3d4f7 100644 --- a/src/rebar3_grisp_io_upload.erl +++ b/src/rebar3_grisp_io_upload.erl @@ -110,8 +110,8 @@ options() -> [ "Force software package building even if it already exists"} ]. --spec get_package(rebar_state:t(), boolean(), binary(), binary(), [binary()]) - -> {ok, rebar_state:t()} | {error, term()}. +-spec get_package(rebar_state:t(), boolean(), atom(), binary(), [binary()]) + -> {ok, binary(), binary(), rebar_state:t()} | {error, term()}. get_package(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> PackageName = rebar3_grisp_util:update_file_name(RState, RelName, RelVsn), PackagePath = rebar3_grisp_util:update_file_path(RState, RelName, RelVsn), @@ -129,7 +129,7 @@ get_package(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> end end. --spec build_package(rebar_state:t(), boolean(), binary(), binary(), [binary()]) +-spec build_package(rebar_state:t(), boolean(), atom(), binary(), [binary()]) -> {ok, rebar_state:t()} | {error, term()}. build_package(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> Args = [ From 3220bc7b62b845fdbee2d0e204fa4d6a83492d9c Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Mon, 7 Oct 2024 17:35:11 +0200 Subject: [PATCH 6/6] Fix tests --- rebar.config | 4 ++++ src/rebar3_grisp_io_api.erl | 2 +- test/rebar3_grisp_io_deploy_SUITE.erl | 3 ++- test/rebar3_grisp_io_upload_SUITE.erl | 7 ++++--- test/rebar3_grisp_io_validate_SUITE.erl | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rebar.config b/rebar.config index 22838d5..9b6d31f 100644 --- a/rebar.config +++ b/rebar.config @@ -12,6 +12,10 @@ ]} ]}. +{plugins, [ + {rebar3_grisp, {git, "git@github.com:grisp/rebar3_grisp", {branch, "master"}}} +]}. + {profiles, [ {test, [ {deps, [ diff --git a/src/rebar3_grisp_io_api.erl b/src/rebar3_grisp_io_api.erl index a1cd901..f1fe914 100644 --- a/src/rebar3_grisp_io_api.erl +++ b/src/rebar3_grisp_io_api.erl @@ -56,7 +56,7 @@ auth(RState, Username, Password) -> Res :: ok | no_return(). update_package(RState, Token, PackageName, PackagePath, Force) -> BaseUrl = base_url(RState), - URI = list_to_binary("/grisp-manager/api/update-package/" ++ PackageName), + URI = <<"/grisp-manager/api/update-package/", PackageName/binary>>, Url = <>, BinSize = filelib:file_size(PackagePath), Etag = <<"\"", PackageName/binary, "\"">>, diff --git a/test/rebar3_grisp_io_deploy_SUITE.erl b/test/rebar3_grisp_io_deploy_SUITE.erl index 41d1ff4..3ca499f 100644 --- a/test/rebar3_grisp_io_deploy_SUITE.erl +++ b/test/rebar3_grisp_io_deploy_SUITE.erl @@ -73,6 +73,7 @@ run_deploy(Config) -> setup_meck_io() -> ok = meck:new(rebar3_grisp_io_io, [no_link]), ok = meck:expect(rebar3_grisp_io_io, ask, fun fake_ask/2), + ok = meck:expect(rebar3_grisp_io_io, console, fun (_, _) -> ok end), ok = meck:expect(rebar3_grisp_io_io, abort, 2, fun (_, [E, S]) -> ct:pal(error, "Error Stack: ~p", [S]), ct:fail("Fail: ~p", [E]) end), ok = meck:expect(rebar3_grisp_io_io, abort, 1, fun(Msg) -> @@ -87,7 +88,7 @@ setup_meck_io() -> setup_meck_gio_utils() -> ok = meck:new(rebar3_grisp_io_utils, [no_link, passthrough]), - ok = meck:expect(rebar3_grisp_io_utils, grisp_pack, fun(RState, _) -> {ok, RState} end). + ok = meck:expect(rebar3_grisp_io_utils, grisp_pack, fun(RState, _, _) -> {ok, RState} end). fake_ask("Local password", _) -> <<"azerty">>. diff --git a/test/rebar3_grisp_io_upload_SUITE.erl b/test/rebar3_grisp_io_upload_SUITE.erl index a449ddd..2cf0ed0 100644 --- a/test/rebar3_grisp_io_upload_SUITE.erl +++ b/test/rebar3_grisp_io_upload_SUITE.erl @@ -50,7 +50,7 @@ end_per_testcase(_, _Config) -> run_upload(Config) -> RState = ?config(rebar_state, Config), - RState1 = rebar_state:dir(RState, ?config(data_dir, Config)), + RState1 = rebar_state:set(RState, root_dir, ?config(data_dir, Config)), ProviderOutput = rebar3_grisp_io_test_utils:run_grisp_io_command(RState1, ?PROV, @@ -64,15 +64,16 @@ run_upload(Config) -> setup_meck_io() -> ok = meck:new(rebar3_grisp_io_io, [no_link]), ok = meck:expect(rebar3_grisp_io_io, ask, fun fake_ask/2), + ok = meck:expect(rebar3_grisp_io_io, console, fun (_, _) -> ok end), ok = meck:expect(rebar3_grisp_io_io, abort, 2, fun (_, [E, S]) -> ct:pal(error, "Error Stack: ~p", [S]), ct:fail("Fail: ~p", [E]) end), ok = meck:expect(rebar3_grisp_io_io, abort, 1, fun (Msg) -> ct:fail(Msg) end), - ok = meck:expect(rebar3_grisp_io_io, success, 1, fun (_) -> ok end). + ok = meck:expect(rebar3_grisp_io_io, success, 2, fun (_, _) -> ok end). setup_meck_gio_utils() -> ok = meck:new(rebar3_grisp_io_utils, [no_link, passthrough]), - ok = meck:expect(rebar3_grisp_io_utils, grisp_pack, fun(RState, _) -> {ok, RState} end). + ok = meck:expect(rebar3_grisp_io_utils, grisp_pack, fun(RState, _, _) -> {ok, RState} end). fake_ask("Local password", _) -> <<"azerty">>. diff --git a/test/rebar3_grisp_io_validate_SUITE.erl b/test/rebar3_grisp_io_validate_SUITE.erl index a6ec460..7b2ebdd 100644 --- a/test/rebar3_grisp_io_validate_SUITE.erl +++ b/test/rebar3_grisp_io_validate_SUITE.erl @@ -72,6 +72,7 @@ run_validate(Config) -> setup_meck_io() -> ok = meck:new(rebar3_grisp_io_io, [no_link]), ok = meck:expect(rebar3_grisp_io_io, ask, fun fake_ask/2), + ok = meck:expect(rebar3_grisp_io_io, console, fun (_, _) -> ok end), ok = meck:expect(rebar3_grisp_io_io, abort, 2, fun (_, [E, S]) -> ct:pal(error, "Error Stack: ~p", [S]), ct:fail("Fail: ~p", [E]) end), ok = meck:expect(rebar3_grisp_io_io, abort, 1, fun(Msg) -> @@ -86,7 +87,7 @@ setup_meck_io() -> setup_meck_gio_utils() -> ok = meck:new(rebar3_grisp_io_utils, [no_link, passthrough]), - ok = meck:expect(rebar3_grisp_io_utils, grisp_pack, fun(RState, _) -> {ok, RState} end). + ok = meck:expect(rebar3_grisp_io_utils, grisp_pack, fun(RState, _, _) -> {ok, RState} end). fake_ask("Local password", _) -> <<"azerty">>.