Skip to content

Create interface and mock for matcher #6374

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

Merged
merged 7 commits into from
Oct 18, 2024

Conversation

fimanishi
Copy link
Member

@fimanishi fimanishi commented Oct 17, 2024

What changed?
Created interface and mock for matcher

Why?
To make it easier to test the taskListManager

How did you test it?
Unit tests passed and tested locally to make sure tasks were still offered

Potential risks
Need to ensure that this doesn't affect the usage of the matcher.go

Release notes

Documentation Changes

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.79%. Comparing base (f2452ed) to head (896d2ec).
Report is 2 commits behind head on master.

Additional details and impacted files
Files with missing lines Coverage Δ
service/matching/tasklist/matcher.go 65.64% <100.00%> (+1.44%) ⬆️
service/matching/tasklist/task_list_manager.go 67.86% <100.00%> (-2.84%) ⬇️

... and 579 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 f2452ed...896d2ec. Read the comment docs.

}
}

return false, nil
}
}

func (tm *TaskMatcher) offerOrTimeout(ctx context.Context, startT time.Time, task *InternalTask) (bool, error) {
// OfferOrTimeout offers a task to a poller and blocks until a poller picks up the task or context timeouts
func (tm *taskMatcherImpl) OfferOrTimeout(ctx context.Context, startT time.Time, task *InternalTask) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

What was the reason for making this public? I am not sure you need to if you're just doing test coverage?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I'm setting the matcher as the interface TaskMatcher in the task_list_manager in order to be able to mock it. But offerOrTimeout is called in the tast_list_manager from the matcher, and because it implements the interface, it doesn't expose the private methods from the implementation. I can probably define the private method in the interface, but from what I look it's not idiomatic

@fimanishi fimanishi merged commit 877ccae into cadence-workflow:master Oct 18, 2024
18 checks passed
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.

2 participants