From 9063abe5f776495aa8fd9f4c42f935d7c63183d3 Mon Sep 17 00:00:00 2001 From: cyb3r4nt <104218001+cyb3r4nt@users.noreply.github.com> Date: Tue, 6 Aug 2024 01:10:03 +0300 Subject: [PATCH] fail TestAuthErrorHTTPHandler if actual HTTP handler is called --- middleware/auth_test.go | 3 ++- v2/middleware/auth_test.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/middleware/auth_test.go b/middleware/auth_test.go index 0c41305..c923b1a 100644 --- a/middleware/auth_test.go +++ b/middleware/auth_test.go @@ -532,7 +532,8 @@ func TestAuthErrorHTTPHandler(t *testing.T) { handler := http.HandlerFunc( func(w http.ResponseWriter, _ *http.Request) { // token required - _, _ = w.Write([]byte("response body\n")) + _, _ = w.Write([]byte("must not be called\n")) + t.Error("auth error must be raised before this HTTP handler is called") }, ) diff --git a/v2/middleware/auth_test.go b/v2/middleware/auth_test.go index 035ceea..37baa62 100644 --- a/v2/middleware/auth_test.go +++ b/v2/middleware/auth_test.go @@ -530,8 +530,9 @@ func TestAuthErrorHTTPHandler(t *testing.T) { a.AuthErrorHTTPHandler = testErrorHandler1 handler := http.HandlerFunc( - func(w http.ResponseWriter, _ *http.Request) { // token required - _, _ = w.Write([]byte("response body\n")) + func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte("must not be called\n")) + t.Error("auth error must be raised before this HTTP handler is called") }, )