From 83b7284b3dc9f7dd8ec5180b2be17337d774a0f6 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Tue, 11 Jul 2023 17:14:30 +0800 Subject: [PATCH] chore: unnecessary use of fmt.Sprintf --- authenticate/handlers_test.go | 6 +++--- pkg/cryptutil/hmac_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/authenticate/handlers_test.go b/authenticate/handlers_test.go index 4f6cd5628f1..1a33a820357 100644 --- a/authenticate/handlers_test.go +++ b/authenticate/handlers_test.go @@ -60,7 +60,7 @@ func TestAuthenticate_RobotsTxt(t *testing.T) { if status := rr.Code; status != http.StatusOK { t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) } - expected := fmt.Sprintf("User-agent: *\nDisallow: /") + expected := "User-agent: *\nDisallow: /" if rr.Body.String() != expected { t.Errorf("handler returned wrong body: got %v want %v", rr.Body.String(), expected) } @@ -78,7 +78,7 @@ func TestAuthenticate_Handler(t *testing.T) { rr := httptest.NewRecorder() h.ServeHTTP(rr, req) - expected := fmt.Sprintf("User-agent: *\nDisallow: /") + expected := "User-agent: *\nDisallow: /" body := rr.Body.String() if body != expected { @@ -92,7 +92,7 @@ func TestAuthenticate_Handler(t *testing.T) { req.Header.Set("Access-Control-Request-Headers", "X-Requested-With") rr = httptest.NewRecorder() h.ServeHTTP(rr, req) - expected = fmt.Sprintf("User-agent: *\nDisallow: /") + expected = "User-agent: *\nDisallow: /" code := rr.Code if code/100 != 2 { t.Errorf("bad preflight code %v", code) diff --git a/pkg/cryptutil/hmac_test.go b/pkg/cryptutil/hmac_test.go index 041945e30cc..dee0fff3f02 100644 --- a/pkg/cryptutil/hmac_test.go +++ b/pkg/cryptutil/hmac_test.go @@ -56,8 +56,8 @@ func TestValidTimestamp(t *testing.T) { {"good - now + 200ms", fmt.Sprint(time.Now().Add(200 * time.Millisecond).Unix()), false}, {"bad - now + 10m", fmt.Sprint(time.Now().Add(10 * time.Minute).Unix()), true}, {"bad - now - 10m", fmt.Sprint(time.Now().Add(-10 * time.Minute).Unix()), true}, - {"malformed - non int", fmt.Sprint("pomerium"), true}, - {"malformed - negative number", fmt.Sprint("-1"), true}, + {"malformed - non int", "pomerium", true}, + {"malformed - negative number", "-1", true}, {"malformed - huge number", fmt.Sprintf("%d", 10*10000000000), true}, } for _, tt := range tests {