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

admin_db_clean_cmd test Part II #6437

Merged
merged 16 commits into from
Oct 30, 2024
Merged

Conversation

bowenxia
Copy link
Contributor

@bowenxia bowenxia commented Oct 28, 2024

What changed?

  • Add more tests for admin_db_clean_cmd
  • Add tests for WithIOHandler and WithManagerFactory to pass the build
  • Refactored initializeInvariantManager into ManagerFactory as well, since it is inside of fixExeuction. Increased testability
  • Renamed PersistenceManagerFactory to be ManagerFactory since initializeInvariantManager is not a persistence manager.
  • mock only ManagerFactory interface instead of all interfaces in the folder
  • Add database_test.go to pass codecov build

Why?
code coverage

How did you test it?
unit test

Potential risks

Release notes

Documentation Changes

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 63.26531% with 36 lines in your changes missing coverage. Please review.

Project coverage is 78.36%. Comparing base (5b096d1) to head (7c52a20).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
tools/cli/mock_manager_factory.go 55.00% 27 Missing ⚠️
tools/cli/database.go 62.50% 3 Missing ⚠️
tools/cli/admin_db_clean_command.go 86.66% 2 Missing ⚠️
tools/cli/admin_db_scan_command.go 0.00% 2 Missing ⚠️
tools/cli/admin_commands.go 0.00% 1 Missing ⚠️
tools/cli/admin_timers.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
tools/cli/app.go 96.77% <100.00%> (+3.05%) ⬆️
tools/cli/admin_commands.go 26.78% <0.00%> (+16.15%) ⬆️
tools/cli/admin_timers.go 0.00% <0.00%> (ø)
tools/cli/admin_db_clean_command.go 85.71% <86.66%> (+56.12%) ⬆️
tools/cli/admin_db_scan_command.go 0.00% <0.00%> (ø)
tools/cli/database.go 47.27% <62.50%> (+10.29%) ⬆️
tools/cli/mock_manager_factory.go 55.00% <55.00%> (ø)

... and 19 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b096d1...7c52a20. Read the comment docs.

@bowenxia bowenxia changed the title Admin db clean cmd test 01 Admin db clean cmd test Part II Oct 30, 2024
@bowenxia bowenxia changed the title Admin db clean cmd test Part II admin_db_clean_cmd test Part II Oct 30, 2024
tools/cli/admin_db_clean_command.go Outdated Show resolved Hide resolved
if err != nil {
return invariant.ManagerFixResult{}, fmt.Errorf("Error in fix execution: %w", err)
return invariant.ManagerFixResult{}, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are errors not wrapped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it is wrapped in the caller side in if err != nil { return commoncli.Problem("Error in fix execution: ", err) }

set.Var(cli.NewStringSlice("CollectionHistory", "CollectionDomain"), FlagInvariantCollection, "invariant collection flag")

// Set actual values for the flags
_ = set.Set(FlagScanType, "ConcreteExecutionType")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: check for errors in tests also. If this fails, the test will fail with an unrelated error, and it will be harder to track the issue.

My suggestion - use

require.NoError(t, set.Set(FlagScanType, "ConcreteExecutionType"))

tools/cli/app.go Show resolved Hide resolved
tools/cli/database_mock.go Outdated Show resolved Hide resolved
@bowenxia bowenxia enabled auto-merge (squash) October 30, 2024 20:23
@bowenxia bowenxia merged commit 21b40bd into master Oct 30, 2024
17 of 19 checks passed
@bowenxia bowenxia deleted the xbowen/Admin_db_clean_cmd_test_01 branch October 30, 2024 20:54
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

Successfully merging this pull request may close these issues.

3 participants