Skip to content

Commit

Permalink
fail TestAuthErrorHTTPHandler if actual HTTP handler is called
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3r4nt committed Aug 5, 2024
1 parent 29a6525 commit 9063abe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion middleware/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
)

Expand Down
5 changes: 3 additions & 2 deletions v2/middleware/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
)

Expand Down

0 comments on commit 9063abe

Please sign in to comment.