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

[YUNIKORN-2623] Create unit tests for Clients #839

Closed
wants to merge 2 commits into from

Conversation

pbacsko
Copy link
Contributor

@pbacsko pbacsko commented May 13, 2024

What is this PR for?

Create mock for SharedIndexedInformer and update existing types.
Write new unit tests for client.Clients.

What type of PR is it?

  • - Bug Fix
  • - Improvement
  • - Feature
  • - Documentation
  • - Hot Fix
  • - Refactoring

Todos

  • - Task

What is the Jira issue?

https://issues.apache.org/jira/browse/YUNIKORN-2623

How should this be tested?

Screenshots (if appropriate)

Questions:

  • - The licenses files need update.
  • - There is breaking changes for older versions.
  • - It needs documentation.

@pbacsko pbacsko self-assigned this May 13, 2024
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 57.35294% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 67.29%. Comparing base (81058ad) to head (60feb0c).
Report is 3 commits behind head on master.

Files Patch % Lines
pkg/common/test/shared_informer_mock.go 26.66% 22 Missing ⚠️
pkg/client/apifactory_mock.go 73.91% 6 Missing ⚠️
pkg/common/test/configmap_informer_mock.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #839      +/-   ##
==========================================
+ Coverage   66.06%   67.29%   +1.22%     
==========================================
  Files          69       70       +1     
  Lines        7550     7592      +42     
==========================================
+ Hits         4988     5109     +121     
+ Misses       2350     2271      -79     
  Partials      212      212              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

noOfInformers = 9
)

func TestWaitForSync(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can do a bit refactor to Clients to simplify the test.

  1. add a new method informers to Clients to return all informers
  2. rewrite WaitForSync and Run by looping all informers
  3. in this test we can create a mock clients to override the new method informers to return a single mock informer

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we do it a separate ticket? In this one I'd rather just focus on the new tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@pbacsko thanks for this patch!

pkg/client/apifactory_mock.go Outdated Show resolved Hide resolved
pkg/client/clients_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

LGTM

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