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

Unit tests for LeaseTaskList #6042

Merged

Conversation

jakobht
Copy link
Member

@jakobht jakobht commented May 22, 2024

What changed?

  • Unit tests for LeaseTaskList
  • Added types for constants to avoid manual conversion in tests
  • Fixed but where the wrong error was returned

Why?
Increase coverage

How did you test it?

Potential risks

Release notes

Documentation Changes

assert.ErrorContains(t, err, assert.AnError.Error())
}

func TestLeaseTaskList_selectErrNotFound(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be easier to read this as a table test:

for _, tc := []struct{
   name string
   prepareDB(*db.Mock)
   assertError func(t *testing.T, err error)
   assertResult func(t * testing.T, res)
}

It would be easier to assess if all possible cases are covered, and it should be easier to read.

Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.68%. Comparing base (96c47bc) to head (cfb5799).
Report is 1 commits behind head on master.

Additional details and impacted files
Files Coverage Δ
common/persistence/nosql/nosql_task_store.go 43.82% <100.00%> (+24.25%) ⬆️

... and 8 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 96c47bc...cfb5799. Read the comment docs.

@jakobht jakobht force-pushed the no_sql_task_store_test_LeaseTaskList branch from 192dfcb to 18e05bc Compare May 23, 2024 06:40
@jakobht jakobht requested a review from shijiesheng as a code owner May 23, 2024 06:40
@jakobht jakobht force-pushed the no_sql_task_store_test_LeaseTaskList branch from 18e05bc to 725cad2 Compare May 24, 2024 09:15
Copy link
Member

@3vilhamster 3vilhamster left a comment

Choose a reason for hiding this comment

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

LGTM, though I suggest moving helpers down the file.
But this is more of a nit style opinion

@jakobht jakobht force-pushed the no_sql_task_store_test_LeaseTaskList branch from 725cad2 to cfb5799 Compare May 24, 2024 09:23
@coveralls
Copy link

Pull Request Test Coverage Report for Build 018fa9e9-e31c-40b5-97ac-941c9c147468

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 55 unchanged lines in 18 files lost coverage.
  • Overall coverage decreased (-0.01%) to 69.42%

Files with Coverage Reduction New Missed Lines %
service/history/task/transfer_standby_task_executor.go 2 86.21%
common/task/weighted_round_robin_task_scheduler.go 2 88.06%
common/task/parallel_task_processor.go 2 93.06%
service/matching/tasklist/db.go 2 73.23%
common/peerprovider/ringpopprovider/config.go 2 81.58%
service/matching/tasklist/task_list_manager.go 2 76.48%
common/persistence/sql/sqlplugin/mysql/task.go 2 73.68%
service/history/execution/mutable_state_util.go 2 78.52%
common/membership/hashring.go 2 84.69%
common/persistence/sql/sqlplugin/mysql/db.go 2 79.49%
Totals Coverage Status
Change from base Build 018fa9d1-f951-43c8-8e3e-3538fa7befdb: -0.01%
Covered Lines: 102338
Relevant Lines: 147418

💛 - Coveralls

@jakobht jakobht merged commit fc6fae5 into cadence-workflow:master May 24, 2024
20 checks passed
timl3136 pushed a commit to timl3136/cadence that referenced this pull request Jun 6, 2024
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