Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing and ENV variables #136

Open
stepanstipl opened this issue Apr 23, 2021 · 2 comments
Open

Testing and ENV variables #136

stepanstipl opened this issue Apr 23, 2021 · 2 comments
Assignees

Comments

@stepanstipl
Copy link
Contributor

stepanstipl commented Apr 23, 2021

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

    @dark0dave added some notes just not to forget ;)

@ghost
Copy link

ghost commented Apr 23, 2021

BIG 👍
from me!

@github-actions github-actions bot added the stale label Dec 14, 2022
@doitintl doitintl deleted a comment from github-actions bot Dec 15, 2022
@stepanstipl
Copy link
Contributor Author

Not stale - we should polish and move this info to some dev docs.

@dark0dave dark0dave self-assigned this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants