{"id":16726934,"url":"https://github.com/lpil/temporary-env","last_synced_at":"2025-03-23T15:31:01.552Z","repository":{"id":62430374,"uuid":"44455934","full_name":"lpil/temporary-env","owner":"lpil","description":"A tool for managing application environment state within tests.","archived":false,"fork":false,"pushed_at":"2017-05-08T22:37:12.000Z","size":10,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T21:50:52.808Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lpil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-17T21:50:13.000Z","updated_at":"2023-09-01T10:46:41.000Z","dependencies_parsed_at":"2022-11-01T20:17:31.313Z","dependency_job_id":null,"html_url":"https://github.com/lpil/temporary-env","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Ftemporary-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Ftemporary-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Ftemporary-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Ftemporary-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lpil","download_url":"https://codeload.github.com/lpil/temporary-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245122701,"owners_count":20564358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T22:55:16.117Z","updated_at":"2025-03-23T15:31:01.307Z","avatar_url":"https://github.com/lpil.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"TemporaryEnv\n============\n\n[![Build Status](https://travis-ci.org/lpil/temporary-env.svg?branch=master)](https://travis-ci.org/lpil/temporary-env)\n[![Hex downloads](https://img.shields.io/hexpm/dt/temporary_env.svg \"Hex downloads\")](https://hex.pm/packages/temporary_env)\n[![Hex version](https://img.shields.io/hexpm/v/temporary_env.svg \"Hex version\")](https://hex.pm/packages/temporary_env)\n\n\nTemporarily set an Application environment value within a block, for when you\nneed to test behaviour that depends on Application environment values.\n\n```elixir\nTemporaryEnv.put :my_app, :greeting, \"Hello!\" do\n  # :greeting for :my_app is now \"Hello!\"\nend\n# :greeting for :my_app is back to its original value\n\nTemporaryEnv.delete :my_app, :greeting do\n  # :greeting for :my_app now has no value\nend\n# :greeting for :my_app is back to its original value\n```\n\nThis *does* modify global state, so do not use it in an async situation.\n\n## Usage\n\nAdd it as a mix dependancy.\n\n```elixir\n# mix.exs\ndef deps do\n  [{:temporary_env, \"~\u003e 2.0\", only: :test, runtime: false}]\nend\n```\n\nInstall this new dependancy.\n\n```\nmix deps.get\n```\n\nUse it in your tests, but only in cases with async set to false.\n\n```elixir\n# test/some_example_test.exs\ndefmodule SomeExampleTest do\n  use ExUnit, async: false\n  use TemporaryEnv\n\n  test \"TemporaryEnv works\" do\n    TemporaryEnv.put :my_app, :greeting, \"Hello, world!\" do\n      value = Application.get_env :my_app, :greeting\n      assert value == \"Hello, world!\"\n    end\n    value = Application.get_env :my_app, :greeting\n    assert value == nil\n  end\nend\n```\n\n\n# LICENCE\n\n```\nTemporaryEnv\nCopyright © 2015 - present Louis Pilfold - MIT Licence\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\nOR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpil%2Ftemporary-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flpil%2Ftemporary-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpil%2Ftemporary-env/lists"}