diff --git a/src/tsuru_application.erl b/src/tsuru_application.erl index 743b8ebe8f7abb78f351d95b3bdb735827d8c66f..06514d3fc78d501cedde553efb6b3b58206dac3b 100644 --- a/src/tsuru_application.erl +++ b/src/tsuru_application.erl @@ -2,7 +2,10 @@ -author("erikh"). %% API --export([get_os_env/1]). +-export([set_env/1, get_os_env/1]). + +set_env(Application) -> + [{application:set_env(Application, Name, Value, [{timeout, infinity}, {persistent, true}]), {Name, Value}} || {Name, Value} <- get_os_env(Application)]. get_os_env(Application) -> Pattern = string:to_upper(atom_to_list(Application)) ++ "_(.+)=(.+)", diff --git a/test/tsuru_application_test.erl b/test/tsuru_application_test.erl index 0af7f87d6df485bd5e50d98b5cb5ca96490d8b47..deb8b63aa80a81da9de9e00dc19870962924db32 100644 --- a/test/tsuru_application_test.erl +++ b/test/tsuru_application_test.erl @@ -8,9 +8,9 @@ get_os_env_test() -> os:putenv("TEST_NON_EVAL", "/1/2/3"), os:putenv("TEST_STRING", "\"/1/2/3\""), os:putenv("TEST_ATOM", "'/1/2/3'"), - ?assertEqual(tsuru_application:get_os_env(test), [ - {atom, '/1/2/3'}, - {non_eval, "/1/2/3"}, - {number, 123}, - {string, "/1/2/3"} + ?assertEqual(tsuru_application:set_env(test), [ + {ok, {atom, '/1/2/3'}}, + {ok, {non_eval, "/1/2/3"}}, + {ok, {number, 123}}, + {ok, {string, "/1/2/3"}} ]).