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

How do you make a test that doesn't fail if dotenv() doesn't find the .env file? #62

Closed
valentinegb opened this issue Jan 15, 2023 · 3 comments

Comments

@valentinegb
Copy link

In my Rust program, I have a .env file for my environmental variables when I run the tests on my computer. However, I also run the tests via a GitHub workflow, where I have a repository secret defined. Currently, these tests all fail in the workflow because there is no .env file present. How should I resolve this?

@valentinegb
Copy link
Author

Right now I'm just doing this:

#![allow(unused_must_use)]
dotenv();

But I'd rather not have to disable any warnings.

@allan2
Copy link
Owner

allan2 commented Jan 15, 2023

dotenv() returns Result. You can handle the error or ignore it.

dotenv().ok(); // discards the error if there is one

@valentinegb
Copy link
Author

Oh- yeah, duh, thanks lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants