octolab / pkg

🧰 Go packages.

Home Page:https://go.octolab.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

testing: env: refactor SetEnvs

kamilsk opened this issue · comments

Setenv will be available at go 1.17: https://tip.golang.org/pkg/testing/#T.Setenv

pkg/testing/env.go

Lines 46 to 48 in d8517c0

func SetEnvs(handle func(error), vars ...env.Variable) (func(func(error)), error) {
return setEnvs(os.LookupEnv, os.Setenv, os.Unsetenv, handle, vars...)
}

also, T.Cleanup is present, so I can extend for example testing.SetEnv to use it, see golang/mock@6d816de