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

Rewrite tests to use a local Viper instance #1700

Closed
1 task done
sagikazarmark opened this issue Dec 6, 2023 · 3 comments · Fixed by #1791
Closed
1 task done

Rewrite tests to use a local Viper instance #1700

sagikazarmark opened this issue Dec 6, 2023 · 3 comments · Fixed by #1791
Labels
kind/enhancement New feature or request

Comments

@sagikazarmark
Copy link
Collaborator

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Problem Description

Most tests currently use the global Viper instance which causes all kinds of trouble between tests.

Proposed Solution

Rewrite tests to initialize a new, local Viper instance.

Alternatives Considered

No response

Additional Information

No response

@sagikazarmark sagikazarmark added the kind/enhancement New feature or request label Dec 6, 2023
Copy link

github-actions bot commented Dec 6, 2023

👋 Thanks for reporting!

A maintainer will take a look at your issue shortly. 👀

In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news,
either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

Thank you! ❤️

@smukk9
Copy link
Contributor

smukk9 commented Mar 4, 2024

Hi @sagikazarmark ,

Thanks for your work. i have used viper recently and would like to help with this.

Are you referring to test like these

func TestAutoEnv(t *testing.T) {
.
func TestAutoEnvWithPrefix(t *testing.T) {

func TestSetEnvKeyReplacer(t *testing.T) {

i see some of the test are already using new like here

v := New()

any additional hints or pointers you can provide would be immensely helpful.

Thanks

@sagikazarmark
Copy link
Collaborator Author

Hey @smukk9 !

Thanks for the kind words!

Yes, these are exactly the kind of tests that I'd like to see refactored. They currently use the global Viper instance which requires all tests to reset Viper first and makes parallelization nearly impossible.

Ideally, each test should initialize their own Viper instance.

sagikazarmark pushed a commit that referenced this issue Apr 7, 2024
* fix:test to use local viper instance

* fix linting

* fix typo

* remove unsed function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants