vendredi 5 février 2021

Mocking os.GetEnv("ENV_VAR")

I am trying to mock the Go function os.GetEnv() in my test files so that I can get the desired value for a particular environment variable.

For example I have defined.

abc := os.GetEnv("XYZ_URL")

Here I should be able to get the needed value for the variable abc. Also I have several places with the GetEnv functions.

It will be really helpful if someone can give me a workaround without the help of any Go framework.

Aucun commentaire:

Enregistrer un commentaire