-
Notifications
You must be signed in to change notification settings - Fork 40.9k
tests: add more units #132541
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
base: master
Are you sure you want to change the base?
tests: add more units #132541
Conversation
Signed-off-by: Alex Pana <[email protected]>
Hi @acpana. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: acpana The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/release-note-none |
/cc @ffromani @SergeyKanzhelev We have some contributors trying to close some of the gaps for kubelet unit test coverage (related: #109717), and generally trying to make some entry-level contributions, this is part of that /kind cleanup |
/ok-to-test |
/retest |
envs: []v1.EnvVar{ | ||
{Name: "FOO", Value: "foo-value"}, | ||
}, | ||
expected: []string{"echo", "foo-value", "$(MISSING)"}, // should this behave as "echo", "foo-value", "" ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to move the comment you added here to the docs of ExpandContainerCommandOnlyStatic
. Something like "missing env vars will stay not expanded". I don't think the behavior can be changed now
Signed-off-by: Alex Pana <[email protected]>
/retest |
Signed-off-by: Alex Pana <[email protected]>
f02839c
to
776382d
Compare
filtered.Eventf(implicit, "Normal", "Reason", "MessageFmt") | ||
filtered.AnnotatedEventf(implicit, map[string]string{"a": "b"}, "Normal", "Reason", "MessageFmt") | ||
|
||
if len(recorder.events) != 1 || len(recorder.fEvents) != 1 || len(recorder.aEvents) != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove the if statement
|
||
func TestIsHostNetworkPod(t *testing.T) { | ||
pod := &v1.Pod{Spec: v1.PodSpec{HostNetwork: true}} | ||
if !IsHostNetworkPod(pod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conditional here isn't needed. Same below.
} | ||
runtimeName := "docker" | ||
runningPod := ConvertPodStatusToRunningPod(runtimeName, podStatus) | ||
if runningPod.ID != podStatus.ID || runningPod.Name != podStatus.Name || runningPod.Namespace != podStatus.Namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the outer conditionals and just assert directly. Same below.
assert.Equal(t, podStatus.Name, runningPod.Name, "ConvertPodStatusToRunningPod did not copy pod Name correctly") | ||
assert.Equal(t, podStatus.Namespace, runningPod.Namespace, "ConvertPodStatusToRunningPod did not copy pod Namespace correctly") | ||
} | ||
assert.Len(t, runningPod.Containers, 1, "expected 1 running container, got %d", len(runningPod.Containers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either change this to a require and remove the following if len(...
, or you can branch on this directly:
if assert.Len(/* ... */) {
// ...
Signed-off-by: Alex Pana <[email protected]>
What type of PR is this?
kind/cleanup
What this PR does / why we need it:
Adds units around helper functions that @natasha41575 identified could use more coverage.
Which issue(s) this PR is related to:
n/a
Special notes for your reviewer:
Does this PR introduce a user-facing change?
no
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
n/a