You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are some notes on tests with Env variables, mostly discussed in context of #127, so not to forget:
Tests preferably should not rely on ENV variables, however, there are some, where we test functionality that is directly related to env variable (such as TestNewFromFlagsKubeconfigHome). In such cases it would be nice to:
Test should not rely on external environment, i.e. it should set/unset its variables at the beginning (i.e. should be self-contained)
Test should return the env to a previous state, i.e. no variables should be leaked (it should not just unset the var, but actually revert, also there's a diff between var being empty and unset(
Ideally, we keep in mind tests can be run in parallel -> i.e. in case tests happen to use same variable this should be accounted for, perhaps some locking mechanism might be needed.
By default go does not run tests in the same file in parallel, unless t.Parallel() is called
However, tests in different packages are by default run in parallel
These are some notes on tests with Env variables, mostly discussed in context of #127, so not to forget:
Tests preferably should not rely on ENV variables, however, there are some, where we test functionality that is directly related to env variable (such as TestNewFromFlagsKubeconfigHome). In such cases it would be nice to:
Test should not rely on external environment, i.e. it should set/unset its variables at the beginning (i.e. should be self-contained)
Test should return the env to a previous state, i.e. no variables should be leaked (it should not just unset the var, but actually revert, also there's a diff between var being empty and unset(
Ideally, we keep in mind tests can be run in parallel -> i.e. in case tests happen to use same variable this should be accounted for, perhaps some locking mechanism might be needed.
t.Parallel()
is called@dark0dave added some notes just not to forget ;)
The text was updated successfully, but these errors were encountered: