From ee9ad07748b823f4e2d951b1c5bba8310ff09bb4 Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Thu, 15 Aug 2019 20:31:42 +0100 Subject: Allow for API callers to define arbitrary overlay variables --- test/rlx_release_SUITE.erl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'test/rlx_release_SUITE.erl') diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl index d7340de..b6289d6 100644 --- a/test/rlx_release_SUITE.erl +++ b/test/rlx_release_SUITE.erl @@ -818,12 +818,15 @@ overlay_release(Config) -> goal_app_2]}]), VarsFile1 = filename:join([LibDir1, "vars1.config"]), - %% tpl_var is defined in vars1, but redifined in vars2 using template. + ProfileString = "prod-v5", + %% `tpl_var' is defined in vars1, but redifined in vars2 using template. + %% `profile_string' is to be injected as an API caller overlay var rlx_test_utils:write_config(VarsFile1, [{yahoo, "yahoo"}, {yahoo2, [{foo, "bar"}]}, {foo_yahoo, "foo_{{yahoo}}"}, {foo_dir, "foodir"}, - {tpl_var, "defined in vars1"}]), + {tpl_var, "defined in vars1"}, + {profile_string_value, "{{profile_string}}"}]), VarsFile2 = filename:join([LibDir1, "vars2.config"]), rlx_test_utils:write_config(VarsFile2, [{google, "yahoo"}, @@ -851,8 +854,16 @@ overlay_release(Config) -> OutputDir = filename:join([proplists:get_value(priv_dir, Config), rlx_test_utils:create_random_name("relx-output")]), - {ok, State} = relx:do(undefined, undefined, [], [LibDir1], 3, - OutputDir, ConfigFile), + ApiCallerOverlays = [{profile_string, ProfileString}], + {ok, State} = relx:do([{relname, undefined}, + {relvsn, undefined}, + {goals, []}, + {lib_dirs, [LibDir1]}, + {log_level, 3}, + {output_dir, OutputDir}, + {config, ConfigFile}, + {api_caller_overlays, ApiCallerOverlays}], + ["release"]), [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rlx_state:realized_releases(State)), AppSpecs = rlx_release:applications(Release), @@ -902,7 +913,9 @@ overlay_release(Config) -> %% This should be rendered correctly based on VarsFile2 file, regardless %% of tpl_var defined in VarsFile1 or not. ?assertEqual("Redefined in vars2 with a template value", - proplists:get_value(tpl_var, TemplateData)). + proplists:get_value(tpl_var, TemplateData)), + ?assertEqual(ProfileString, + proplists:get_value(profile_string_value, TemplateData)). make_goalless_release(Config) -> LibDir1 = proplists:get_value(lib1, Config), -- cgit v1.2.3