Skip to content

Commit 7bccbaf

Browse files
committed
fix: enable and fixes rules from testifylint on test package
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent fa75b43 commit 7bccbaf

File tree

19 files changed

+19
-41
lines changed

19 files changed

+19
-41
lines changed

test/e2e/apimachinery/apply.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ import (
3939
admissionapi "k8s.io/pod-security-admission/api"
4040

4141
"github.com/onsi/ginkgo/v2"
42-
43-
// ensure libs have a chance to initialize
44-
_ "github.com/stretchr/testify/assert"
4542
)
4643

4744
var _ = SIGDescribe("ServerSideApply", func() {

test/e2e/apimachinery/crd_conversion_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ import (
4444

4545
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
4646
"k8s.io/apiextensions-apiserver/test/integration"
47-
48-
// ensure libs have a chance to initialize
49-
_ "github.com/stretchr/testify/assert"
5047
)
5148

5249
const (

test/e2e/apimachinery/field_validation.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ limitations under the License.
1717
package apimachinery
1818

1919
import (
20-
// ensure libs have a chance to initialize
2120
"context"
2221
"encoding/json"
2322
"fmt"
2423
"strings"
2524

2625
"github.com/onsi/ginkgo/v2"
27-
_ "github.com/stretchr/testify/assert"
2826
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2927
apiextensionclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
3028
"k8s.io/apiextensions-apiserver/test/integration/fixtures"

test/e2e/apimachinery/openapiv3.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ import (
4242
samplev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1"
4343

4444
"k8s.io/kubernetes/test/e2e/framework"
45-
46-
// ensure libs have a chance to initialize
47-
_ "github.com/stretchr/testify/assert"
4845
)
4946

5047
var _ = SIGDescribe("OpenAPIV3", func() {

test/e2e/apimachinery/webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ import (
5252

5353
"github.com/onsi/ginkgo/v2"
5454
"github.com/onsi/gomega"
55-
56-
// ensure libs have a chance to initialize
57-
_ "github.com/stretchr/testify/assert"
5855
)
5956

6057
const (

test/e2e/framework/expect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestNewGomega(t *testing.T) {
4444
t.Errorf("unexpected failure: %s", err.Error())
4545
}
4646
err := Gomega().Expect("hello").ToNot(gomega.Equal("hello"))
47-
require.NotNil(t, err)
47+
require.Error(t, err)
4848
assert.Equal(t, `Expected
4949
<string>: hello
5050
not to equal

test/e2e/framework/internal/unittests/bugs/bugs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
func TestBugs(t *testing.T) {
30-
assert.NoError(t, framework.FormatBugs())
30+
require.NoError(t, framework.FormatBugs())
3131
RecordBugs()
3232
Describe()
3333

test/e2e/framework/pod/utils_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
"github.com/stretchr/testify/assert"
23+
"github.com/stretchr/testify/require"
2324
v1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/utils/pointer"
@@ -65,7 +66,7 @@ func TestMixinRestrictedPodSecurity(t *testing.T) {
6566
for _, pod := range restrictablePods {
6667
t.Run(pod.Name, func(t *testing.T) {
6768
p := pod // closure
68-
assert.NoError(t, MixinRestrictedPodSecurity(&p))
69+
require.NoError(t, MixinRestrictedPodSecurity(&p))
6970
assert.Equal(t, GetRestrictedPodSecurityContext(), p.Spec.SecurityContext,
7071
"Mixed in PodSecurityContext should equal the from-scratch PodSecurityContext")
7172
assert.Equal(t, GetRestrictedContainerSecurityContext(), p.Spec.Containers[0].SecurityContext,

test/e2e/framework/testfiles/testfiles_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"testing"
2222

2323
"github.com/stretchr/testify/assert"
24+
"github.com/stretchr/testify/require"
2425
)
2526

2627
var (
@@ -49,13 +50,13 @@ func TestEmbeddedFileSource(t *testing.T) {
4950
// read a file which exists and compare the contents
5051
b, err := s.ReadTestFile(fooPath)
5152

52-
assert.NoError(t, err)
53+
require.NoError(t, err)
5354
assert.Equal(t, fooContents, string(b))
5455

5556
// read a non-existent file and ensure that the returned value is empty and error is nil
5657
// Note: this is done so that the next file source can be tried by the caller
5758
b, err = s.ReadTestFile(notExistsPath)
58-
assert.NoError(t, err)
59+
require.NoError(t, err)
5960
assert.Empty(t, b)
6061

6162
// describing the test filesystem should list down all files

test/e2e/node/taints.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import (
3535
admissionapi "k8s.io/pod-security-admission/api"
3636

3737
"github.com/onsi/ginkgo/v2"
38-
// ensure libs have a chance to initialize
39-
_ "github.com/stretchr/testify/assert"
4038
)
4139

4240
const (

0 commit comments

Comments
 (0)