mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Merge pull request #127649 from mmorel-35/testifylint/formatter@k8s.io/kubernetes
fix: enable formatter rule from testifylint in module `k8s.io/kubernetes`
This commit is contained in:
commit
26399fa7be
@ -23726,7 +23726,7 @@ func TestValidateAppArmorProfileFormat(t *testing.T) {
|
|||||||
if test.expectValid {
|
if test.expectValid {
|
||||||
assert.NoError(t, err, "Profile %s should be valid", test.profile)
|
assert.NoError(t, err, "Profile %s should be valid", test.profile)
|
||||||
} else {
|
} else {
|
||||||
assert.Error(t, err, fmt.Sprintf("Profile %s should not be valid", test.profile))
|
assert.Errorf(t, err, "Profile %s should not be valid", test.profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,7 +786,7 @@ func TestFallbackResourcesUsage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(test.description, func(t *testing.T) {
|
t.Run(test.description, func(t *testing.T) {
|
||||||
assert.NotEqual(t, 0, test.usageFunc(), fmt.Sprintf("%s: unexpected fallback value", test.usageFuncName))
|
assert.NotEqualf(t, 0, test.usageFunc(), "%s: unexpected fallback value", test.usageFuncName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2704,8 +2704,7 @@ func TestValidateNodeIPParam(t *testing.T) {
|
|||||||
}
|
}
|
||||||
addrs, err := net.InterfaceAddrs()
|
addrs, err := net.InterfaceAddrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
assert.Error(t, err, fmt.Sprintf(
|
assert.Errorf(t, err, "Unable to obtain a list of the node's unicast interface addresses.")
|
||||||
"Unable to obtain a list of the node's unicast interface addresses."))
|
|
||||||
}
|
}
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
var ip net.IP
|
var ip net.IP
|
||||||
@ -2728,9 +2727,9 @@ func TestValidateNodeIPParam(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
err := validateNodeIP(netutils.ParseIPSloppy(test.nodeIP))
|
err := validateNodeIP(netutils.ParseIPSloppy(test.nodeIP))
|
||||||
if test.success {
|
if test.success {
|
||||||
assert.NoError(t, err, "test %s", test.testName)
|
assert.NoErrorf(t, err, "test %s", test.testName)
|
||||||
} else {
|
} else {
|
||||||
assert.Error(t, err, fmt.Sprintf("test %s", test.testName))
|
assert.Errorf(t, err, "test %s", test.testName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1316,21 +1316,21 @@ func TestValidateContainerLogStatus(t *testing.T) {
|
|||||||
podStatus := &v1.PodStatus{ContainerStatuses: tc.statuses}
|
podStatus := &v1.PodStatus{ContainerStatuses: tc.statuses}
|
||||||
_, err := kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
|
_, err := kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
|
||||||
if !tc.success {
|
if !tc.success {
|
||||||
assert.Error(t, err, fmt.Sprintf("[case %d] error", i))
|
assert.Errorf(t, err, "[case %d] error", i)
|
||||||
} else {
|
} else {
|
||||||
assert.NoError(t, err, "[case %d] error", i)
|
assert.NoErrorf(t, err, "[case %d] error", i)
|
||||||
}
|
}
|
||||||
// Access the log of the previous, terminated container
|
// Access the log of the previous, terminated container
|
||||||
previous = true
|
previous = true
|
||||||
_, err = kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
|
_, err = kubelet.validateContainerLogStatus("podName", podStatus, containerName, previous)
|
||||||
if !tc.pSuccess {
|
if !tc.pSuccess {
|
||||||
assert.Error(t, err, fmt.Sprintf("[case %d] error", i))
|
assert.Errorf(t, err, "[case %d] error", i)
|
||||||
} else {
|
} else {
|
||||||
assert.NoError(t, err, "[case %d] error", i)
|
assert.NoErrorf(t, err, "[case %d] error", i)
|
||||||
}
|
}
|
||||||
// Access the log of a container that's not in the pod
|
// Access the log of a container that's not in the pod
|
||||||
_, err = kubelet.validateContainerLogStatus("podName", podStatus, "blah", false)
|
_, err = kubelet.validateContainerLogStatus("podName", podStatus, "blah", false)
|
||||||
assert.Error(t, err, fmt.Sprintf("[case %d] invalid container name should cause an error", i))
|
assert.Errorf(t, err, "[case %d] invalid container name should cause an error", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3267,10 +3267,10 @@ func TestSyncPodSpans(t *testing.T) {
|
|||||||
assert.NotEmpty(t, runtimeServiceSpans, "syncPod trace should have runtime service spans")
|
assert.NotEmpty(t, runtimeServiceSpans, "syncPod trace should have runtime service spans")
|
||||||
|
|
||||||
for _, span := range imageServiceSpans {
|
for _, span := range imageServiceSpans {
|
||||||
assert.Equal(t, span.Parent.SpanID(), rootSpan.SpanContext.SpanID(), fmt.Sprintf("image service span %s %s should be child of root span", span.Name, span.Parent.SpanID()))
|
assert.Equalf(t, span.Parent.SpanID(), rootSpan.SpanContext.SpanID(), "image service span %s %s should be child of root span", span.Name, span.Parent.SpanID())
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, span := range runtimeServiceSpans {
|
for _, span := range runtimeServiceSpans {
|
||||||
assert.Equal(t, span.Parent.SpanID(), rootSpan.SpanContext.SpanID(), fmt.Sprintf("runtime service span %s %s should be child of root span", span.Name, span.Parent.SpanID()))
|
assert.Equalf(t, span.Parent.SpanID(), rootSpan.SpanContext.SpanID(), "runtime service span %s %s should be child of root span", span.Name, span.Parent.SpanID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1525,6 +1525,6 @@ func TestTrimURLPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
assert.Equal(t, test.expected, getURLRootPath(test.path), fmt.Sprintf("path is: %s", test.path))
|
assert.Equalf(t, test.expected, getURLRootPath(test.path), "path is: %s", test.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4811,7 +4811,7 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) {
|
|||||||
realServers1, rsErr1 := ipvs.GetRealServers(virtualServers1[0])
|
realServers1, rsErr1 := ipvs.GetRealServers(virtualServers1[0])
|
||||||
assert.NoError(t, rsErr1, "Expected no error getting real servers")
|
assert.NoError(t, rsErr1, "Expected no error getting real servers")
|
||||||
|
|
||||||
assert.Len(t, realServers1, tc.expectLocalRealServerNum, fmt.Sprintf("Expected %d real servers", tc.expectLocalRealServerNum))
|
assert.Lenf(t, realServers1, tc.expectLocalRealServerNum, "Expected %d real servers", tc.expectLocalRealServerNum)
|
||||||
for i := 0; i < tc.expectLocalRealServerNum; i++ {
|
for i := 0; i < tc.expectLocalRealServerNum; i++ {
|
||||||
assert.Equal(t, realServers1[i].String(), tc.expectLocalRealServers[i])
|
assert.Equal(t, realServers1[i].String(), tc.expectLocalRealServers[i])
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package apparmor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
@ -45,9 +44,9 @@ func TestValidateBadHost(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
err := v.Validate(getPodWithProfile(test.profile))
|
err := v.Validate(getPodWithProfile(test.profile))
|
||||||
if test.expectValid {
|
if test.expectValid {
|
||||||
assert.NoError(t, err, "Pod with profile %q should be valid", test.profile)
|
assert.NoErrorf(t, err, "Pod with profile %q should be valid", test.profile)
|
||||||
} else {
|
} else {
|
||||||
assert.Equal(t, hostErr, err, "Pod with profile %q should trigger a host validation error", test.profile)
|
assert.Equalf(t, hostErr, err, "Pod with profile %q should trigger a host validation error", test.profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,9 +70,9 @@ func TestValidateValidHost(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
err := v.Validate(getPodWithProfile(test.profile))
|
err := v.Validate(getPodWithProfile(test.profile))
|
||||||
if test.expectValid {
|
if test.expectValid {
|
||||||
assert.NoError(t, err, "Pod with profile %q should be valid", test.profile)
|
assert.NoErrorf(t, err, "Pod with profile %q should be valid", test.profile)
|
||||||
} else {
|
} else {
|
||||||
assert.Error(t, err, fmt.Sprintf("Pod with profile %q should trigger a validation error", test.profile))
|
assert.Errorf(t, err, "Pod with profile %q should trigger a validation error", test.profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user