From 12ce6ef3ad31750360f5aa47fd388e427c077733 Mon Sep 17 00:00:00 2001 From: guangwu Date: Wed, 23 Aug 2023 23:27:41 +0800 Subject: [PATCH] chore: use fmt.Fprintf instead of fmt.Fprint(fmt.Sprintf(...)) (#621) Co-authored-by: Andrew Starr-Bochicchio --- projects_test.go | 8 ++++---- uptime_test.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/projects_test.go b/projects_test.go index ae6574df..5732626a 100644 --- a/projects_test.go +++ b/projects_test.go @@ -28,7 +28,7 @@ func TestProjects_List(t *testing.T) { mux.HandleFunc("/v2/projects", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(expectedProjects) - fmt.Fprint(w, fmt.Sprintf(`{"projects":%s, "meta": {"total": 2}}`, string(resp))) + fmt.Fprintf(w, `{"projects":%s, "meta": {"total": 2}}`, string(resp)) }) projects, resp, err := client.Projects.List(ctx, nil) @@ -133,7 +133,7 @@ func TestProjects_GetDefault(t *testing.T) { mux.HandleFunc("/v2/projects/default", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(project) - fmt.Fprint(w, fmt.Sprintf(`{"project":%s}`, string(resp))) + fmt.Fprintf(w, `{"project":%s}`, string(resp)) }) resp, _, err := client.Projects.GetDefault(ctx) @@ -158,7 +158,7 @@ func TestProjects_GetWithUUID(t *testing.T) { mux.HandleFunc("/v2/projects/project-1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(project) - fmt.Fprint(w, fmt.Sprintf(`{"project":%s}`, string(resp))) + fmt.Fprintf(w, `{"project":%s}`, string(resp)) }) resp, _, err := client.Projects.Get(ctx, "project-1") @@ -347,7 +347,7 @@ func TestProjects_ListResources(t *testing.T) { mux.HandleFunc("/v2/projects/project-1/resources", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(expectedResources) - fmt.Fprint(w, fmt.Sprintf(`{"resources":%s, "meta": {"total": 2}}`, string(resp))) + fmt.Fprintf(w, `{"resources":%s, "meta": {"total": 2}}`, string(resp)) }) resources, resp, err := client.Projects.ListResources(ctx, "project-1", nil) diff --git a/uptime_test.go b/uptime_test.go index e3797e48..1cb63eff 100644 --- a/uptime_test.go +++ b/uptime_test.go @@ -28,7 +28,7 @@ func TestUptimeChecks_List(t *testing.T) { mux.HandleFunc("/v2/uptime/checks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(expectedUptimeChecks) - fmt.Fprint(w, fmt.Sprintf(`{"checks":%s, "meta": {"total": 2}}`, string(resp))) + fmt.Fprintf(w, `{"checks":%s, "meta": {"total": 2}}`, string(resp)) }) uptimeChecks, resp, err := client.UptimeChecks.List(ctx, nil) @@ -149,7 +149,7 @@ func TestUptimeChecks_GetState(t *testing.T) { mux.HandleFunc("/v2/uptime/checks/check-1/state", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(uptimeCheckState) - fmt.Fprint(w, fmt.Sprintf(`{"state":%s}`, string(resp))) + fmt.Fprintf(w, `{"state":%s}`, string(resp)) }) resp, _, err := client.UptimeChecks.GetState(ctx, "check-1") @@ -174,7 +174,7 @@ func TestUptimeChecks_GetWithID(t *testing.T) { mux.HandleFunc("/v2/uptime/checks/check-1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(uptimeCheck) - fmt.Fprint(w, fmt.Sprintf(`{"check":%s}`, string(resp))) + fmt.Fprintf(w, `{"check":%s}`, string(resp)) }) resp, _, err := client.UptimeChecks.Get(ctx, "check-1") @@ -430,7 +430,7 @@ func TestUptimeAlert_GetWithID(t *testing.T) { mux.HandleFunc("/v2/uptime/checks/check-1/alerts/alert-1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(alert) - fmt.Fprint(w, fmt.Sprintf(`{"alert":%s}`, string(resp))) + fmt.Fprintf(w, `{"alert":%s}`, string(resp)) }) resp, _, err := client.UptimeChecks.GetAlert(ctx, "check-1", "alert-1") @@ -481,7 +481,7 @@ func TestUptimeAlerts_List(t *testing.T) { mux.HandleFunc("/v2/uptime/checks/check-1/alerts", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) resp, _ := json.Marshal(expectedAlerts) - fmt.Fprint(w, fmt.Sprintf(`{"alerts":%s, "meta": {"total": 2}}`, string(resp))) + fmt.Fprintf(w, `{"alerts":%s, "meta": {"total": 2}}`, string(resp)) }) alerts, resp, err := client.UptimeChecks.ListAlerts(ctx, "check-1", nil)