From 504934b612339892fad99005fae072adf5d98757 Mon Sep 17 00:00:00 2001 From: pRAnaY Date: Sat, 16 Nov 2024 01:32:17 +0530 Subject: [PATCH] fixed errcheck in test_serve_metrics_plugin (#29289) --- server/.golangci.yml | 1 - .../manual.test_serve_metrics_plugin/main.go | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 8b4dfec6d7..0863df0541 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -120,7 +120,6 @@ issues: channels/app/platform/web_conn.go|\ channels/app/platform/web_hub.go|\ channels/app/platform/web_hub_test.go|\ - channels/app/plugin_api_tests/manual.test_serve_metrics_plugin/main.go|\ channels/app/plugin_api_tests/test_update_user_auth_plugin/main.go|\ channels/app/plugin_install.go|\ channels/app/plugin_signature.go|\ diff --git a/server/channels/app/plugin_api_tests/manual.test_serve_metrics_plugin/main.go b/server/channels/app/plugin_api_tests/manual.test_serve_metrics_plugin/main.go index f2afa8f8cf..a15baa3a72 100644 --- a/server/channels/app/plugin_api_tests/manual.test_serve_metrics_plugin/main.go +++ b/server/channels/app/plugin_api_tests/manual.test_serve_metrics_plugin/main.go @@ -7,6 +7,7 @@ import ( "net/http" "github.com/mattermost/mattermost/server/public/plugin" + "github.com/mattermost/mattermost/server/public/shared/mlog" ) type Plugin struct { @@ -15,11 +16,21 @@ type Plugin struct { func (p *Plugin) ServeMetrics(_ *plugin.Context, w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/subpath" { - w.Write([]byte("METRICS SUBPATH")) + _, err := w.Write([]byte("METRICS SUBPATH")) + if err != nil { + mlog.Error("Failed to write response", mlog.Err(err)) + w.WriteHeader(http.StatusInternalServerError) + return + } return } - w.Write([]byte("METRICS")) + _, err := w.Write([]byte("METRICS")) + if err != nil { + mlog.Error("Failed to write response", mlog.Err(err)) + w.WriteHeader(http.StatusInternalServerError) + return + } } func main() {