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

Create unit-test helper functions #301

Merged
merged 2 commits into from
Aug 2, 2021
Merged

Conversation

clamoriniere
Copy link
Collaborator

@clamoriniere clamoriniere commented May 7, 2021

What does this PR do?

Create new unittest helper to verify specific part of a PodTemplate, DS, EDS

Motivation

easy unit-tests maintenance

Additional Notes

Anything else we should know when reviewing?

Describe your test plan

Write there any instructions and details you may have to test your PR.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: bug, enhancement, documentation

@codecov-commenter
Copy link

codecov-commenter commented May 7, 2021

Codecov Report

Merging #301 (60a3d14) into main (8b4b796) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #301   +/-   ##
=======================================
  Coverage   58.22%   58.22%           
=======================================
  Files          59       59           
  Lines        6300     6300           
=======================================
  Hits         3668     3668           
  Misses       2362     2362           
  Partials      270      270           
Flag Coverage Δ
unittests 58.22% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

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

@clamoriniere clamoriniere changed the title Create unit-test helper function Create unit-test helper functions May 7, 2021
@clamoriniere clamoriniere added this to the v0.7 milestone May 27, 2021
@clamoriniere clamoriniere added the enhancement New feature or request label May 27, 2021
@clamoriniere clamoriniere marked this pull request as ready for review May 27, 2021 16:23
@clamoriniere clamoriniere requested a review from a team as a code owner May 27, 2021 16:23
}

// CheckLabelIsNotPresent used to check if a label (key,value) is not present on a metav1.ObjectMeta object.
func CheckLabelIsNotPresent(key string) CheckObjectMeta {
Copy link
Contributor

Choose a reason for hiding this comment

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

As the functions return the CheckObjectMeta meta type, we cannot easily combine them, e.g. wrapping CheckLabelIsPresent in a not or something, meaning that we'll have to provide a helper each time (regexp, not regexp, etc.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you see a solution?

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 could change to func Check(runtime.Object) bool and use a typed struct to inject other parameters.
Something like:

CheckLabelIsPresent{label: <some_key>}
with func (*CheckLabelIsPresent) Check(runtime.Object) bool

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@clamoriniere clamoriniere merged commit 1ded384 into main Aug 2, 2021
@clamoriniere clamoriniere deleted the clamoriniere/unit-test-v2 branch August 2, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants