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

chore: use testify instead of testing.Fatal #21258

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ func TestSetOptionalRedisPasswordFromKubeConfig(t *testing.T) {
redisOptions = &redis.Options{}
)
if tc.secret != nil {
if _, err := kubeClient.CoreV1().Secrets(tc.namespace).Create(ctx, tc.secret, metav1.CreateOptions{}); err != nil {
t.Fatalf("Failed to create secret: %v", err)
}
_, err := kubeClient.CoreV1().Secrets(tc.namespace).Create(ctx, tc.secret, metav1.CreateOptions{})
require.NoErrorf(t, err, "Failed to create secret")
}
err := SetOptionalRedisPasswordFromKubeConfig(ctx, kubeClient, tc.namespace, redisOptions)
if tc.expectedErr != "" {
Expand Down
5 changes: 2 additions & 3 deletions controller/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
apierr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -726,9 +727,7 @@ func TestShouldHashManifest(t *testing.T) {
test.un.SetAnnotations(test.annotations)
}
got := shouldHashManifest(test.appName, test.gvk, test.un)
if test.want != got {
t.Fatalf("test=%v want %v got %v", test.name, test.want, got)
}
require.Equalf(t, test.want, got, "test=%v", test.name)
})
}
}
4 changes: 1 addition & 3 deletions controller/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,9 +1564,7 @@ func TestUseDiffCache(t *testing.T) {
}
if a != nil {
err := mergo.Merge(app, a, mergo.WithOverride, mergo.WithOverwriteWithEmptyValue)
if err != nil {
t.Fatalf("error merging app: %s", err)
}
require.NoErrorf(t, err, "error merging app")
}
if app.Spec.Destination.Name != "" && app.Spec.Destination.Server != "" {
// Simulate the controller's process for populating both of these fields.
Expand Down
8 changes: 2 additions & 6 deletions notification_controller/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ func TestGetAppProj_invalidProjectNestedString(t *testing.T) {
func TestInit(t *testing.T) {
scheme := runtime.NewScheme()
err := v1alpha1.SchemeBuilder.AddToScheme(scheme)
if err != nil {
t.Fatalf("Error registering the resource: %v", err)
}
require.NoErrorf(t, err, "Error registering the resource")
dynamicClient := fake.NewSimpleDynamicClient(scheme)
k8sClient := k8sfake.NewSimpleClientset()
appLabelSelector := "app=test"
Expand Down Expand Up @@ -141,9 +139,7 @@ func TestInit(t *testing.T) {
func TestInitTimeout(t *testing.T) {
scheme := runtime.NewScheme()
err := v1alpha1.SchemeBuilder.AddToScheme(scheme)
if err != nil {
t.Fatalf("Error registering the resource: %v", err)
}
require.NoErrorf(t, err, "Error registering the resource")
dynamicClient := fake.NewSimpleDynamicClient(scheme)
k8sClient := k8sfake.NewSimpleClientset()
appLabelSelector := "app=test"
Expand Down
Loading