From 59a9b36219cf883f86122cf603fb9133cf464e21 Mon Sep 17 00:00:00 2001 From: alonso fabila Date: Mon, 28 Oct 2024 14:33:33 -0600 Subject: [PATCH] e2e: Fix improper use of formatting When using fmt.Errorf(), we don't need to format the message with fmt.Sprintf(). Fixes: #1618 Signed-off-by: alonso fabila --- e2e/deployers/crud.go | 4 ++-- e2e/dractions/retry.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/deployers/crud.go b/e2e/deployers/crud.go index 9857f7f97..52aeb1942 100644 --- a/e2e/deployers/crud.go +++ b/e2e/deployers/crud.go @@ -252,7 +252,7 @@ func CreatePlacementDecisionConfigMap(cmName string, cmNamespace string) error { err := util.Ctx.Hub.CtrlClient.Create(context.Background(), configMap) if err != nil { if !errors.IsAlreadyExists(err) { - return fmt.Errorf("could not create configMap " + cmName) + return fmt.Errorf("could not create configMap %q", cmName) } util.Ctx.Log.Info("configMap " + cmName + " already Exists") @@ -271,7 +271,7 @@ func DeleteConfigMap(cmName string, cmNamespace string) error { err := util.Ctx.Hub.CtrlClient.Delete(context.Background(), configMap) if err != nil { if !errors.IsNotFound(err) { - return fmt.Errorf("could not delete configMap " + cmName) + return fmt.Errorf("could not delete configMap %q", cmName) } util.Ctx.Log.Info("configMap " + cmName + " not found") diff --git a/e2e/dractions/retry.go b/e2e/dractions/retry.go index b85af0be0..cb4a285f3 100644 --- a/e2e/dractions/retry.go +++ b/e2e/dractions/retry.go @@ -46,7 +46,7 @@ func waitPlacementDecision(client client.Client, namespace string, placementName if time.Since(startTime) > time.Second*time.Duration(util.Timeout) { return "", fmt.Errorf( - "could not get placement decision for " + placementName + " before timeout, fail") + "could not get placement decision for %q before timeout, fail", placementName) } time.Sleep(time.Second * time.Duration(util.TimeInterval)) @@ -78,7 +78,7 @@ func waitDRPCReady(client client.Client, namespace string, drpcName string) erro util.Ctx.Log.Info("drpc " + drpcName + " LastGroupSyncTime is nil") } - return fmt.Errorf("drpc " + drpcName + " is not ready yet before timeout, fail") + return fmt.Errorf("drpc %q is not ready yet before timeout, fail", drpcName) } time.Sleep(time.Second * time.Duration(util.TimeInterval)) @@ -206,7 +206,7 @@ func waitDRPCDeleted(client client.Client, namespace string, name string) error } if time.Since(startTime) > time.Second*time.Duration(util.Timeout) { - return fmt.Errorf(fmt.Sprintf("drpc %s is not deleted yet before timeout, fail", name)) + return fmt.Errorf("drpc %q is not deleted yet before timeout, fail", name) } time.Sleep(time.Second * time.Duration(util.TimeInterval))