{"id":15740873,"url":"https://github.com/tomwright/tmpenv","last_synced_at":"2025-03-31T05:16:15.514Z","repository":{"id":57592927,"uuid":"183427252","full_name":"TomWright/tmpenv","owner":"TomWright","description":"Set temporary environment variables and program arguments.","archived":false,"fork":false,"pushed_at":"2019-04-25T12:38:29.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-06T09:48:18.978Z","etag":null,"topics":["arguments","environment","environment-variables","test","test-driven-development","testing","testing-tools","tests"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomWright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-25T12:12:12.000Z","updated_at":"2024-10-02T00:23:41.000Z","dependencies_parsed_at":"2022-09-26T19:43:27.908Z","dependency_job_id":null,"html_url":"https://github.com/TomWright/tmpenv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Ftmpenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Ftmpenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Ftmpenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomWright%2Ftmpenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomWright","download_url":"https://codeload.github.com/TomWright/tmpenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418645,"owners_count":20773938,"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":["arguments","environment","environment-variables","test","test-driven-development","testing","testing-tools","tests"],"created_at":"2024-10-04T02:41:05.637Z","updated_at":"2025-03-31T05:16:15.491Z","avatar_url":"https://github.com/TomWright.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tmpenv\n\n[![Build Status](https://travis-ci.org/TomWright/tmpenv.svg?branch=master)](https://travis-ci.org/TomWright/tmpenv)\n[![codecov](https://codecov.io/gh/TomWright/tmpenv/branch/master/graph/badge.svg)](https://codecov.io/gh/TomWright/tmpenv)\n[![Documentation](https://godoc.org/github.com/TomWright/tmpenv?status.svg)](https://godoc.org/github.com/TomWright/tmpenv)\n\nEasily set temporary environment variables and commandline flags, usually within a testing environment.\n\n## Quick start\n\n`SetEnvVar`, `SetEnvVars` and `AppendOSArgs` all return a single `func`, which when executed will reset the given variables to their previous state.\n\n*Important note - Things may not work as expected if you run your tests in parallel!*\n\n### Setting environment variables\n\n```\nfunc TestSomething(t *testing.T) {\n    log.Println(os.Getenv(\"A\")) // \"\"\n    \n    t.Run(\"test one\", func(t *testing.T) {\n        resetEnvVars := tmpenv.SetEnvVars(map[string]string{\n            \"A\":     \"123\",\n        })\n        defer resetEnvVars()\n\n        log.Println(os.Getenv(\"A\")) // \"123\"\n    })\n    \n    log.Println(os.Getenv(\"A\")) // \"\"\n    \n    t.Run(\"test two\", func(t *testing.T) {\n        resetEnvVars := tmpenv.SetEnvVars(map[string]string{\n            \"A\":     \"456\",\n        })\n        defer resetEnvVars()\n\n        log.Println(os.Getenv(\"A\")) // \"456\"\n    })\n\n    log.Println(os.Getenv(\"A\")) // \"\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomwright%2Ftmpenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomwright%2Ftmpenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomwright%2Ftmpenv/lists"}