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

Fix tests depending on configuration flag #5650

Merged
merged 18 commits into from
Apr 27, 2020
Merged

Conversation

farazdagi
Copy link
Contributor

@farazdagi farazdagi commented Apr 27, 2020

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

  • properly handles nil values (returns errors instead of segfault)
  • number of tests are updated (most changes are just asserting proper config flag)

Which issues(s) does this PR fix?

Fixes #5648

Other notes for review

  • There's no unhandled featureconfig.Init calls in tests anymore, I've fixed all tests - with one exception TestServer_ListBlocks_Pagination - it is marked as skipped, and I will create a separate issue for it
  • I've moved config setting from init() functions to TestMain() (there were two such ocurrences)
  • New method added to featureconfig:
// InitWithReset sets the global config and returns function that is used to reset configuration.
func InitWithReset(c *Flags) func() {
	resetFunc := func() {
		Init(&Flags{})
	}
	Init(c)
	return resetFunc
}

Please review how it is used, as it will be preferred way to set config params in tests (so suggestions are welcome):

resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{NewStateMgmt:true})
defer resetCfg()

@farazdagi farazdagi requested a review from a team as a code owner April 27, 2020 14:09
@farazdagi farazdagi self-assigned this Apr 27, 2020
@farazdagi farazdagi requested a review from nisdas April 27, 2020 14:09
@farazdagi farazdagi changed the title Fix nil segfaults Fix test depending on configuration flag Apr 27, 2020
@farazdagi farazdagi changed the title Fix test depending on configuration flag Fix tests depending on configuration flag Apr 27, 2020
@codecov
Copy link

codecov bot commented Apr 27, 2020

Codecov Report

Merging #5650 into master will decrease coverage by 1.86%.
The diff coverage is 38.46%.

@@            Coverage Diff             @@
##           master    #5650      +/-   ##
==========================================
- Coverage   22.94%   21.08%   -1.87%     
==========================================
  Files         268      179      -89     
  Lines       23003    16034    -6969     
==========================================
- Hits         5279     3381    -1898     
+ Misses      16856    12096    -4760     
+ Partials      868      557     -311     

rauljordan
rauljordan previously approved these changes Apr 27, 2020
prestonvanloon
prestonvanloon previously approved these changes Apr 27, 2020
@farazdagi farazdagi added Ready For Review A pull request ready for code review and removed In Progress labels Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle nil values in validators.go
3 participants