From 244b9786fc431c362c6f5ac971ac4d04b97f78a2 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 13 Jan 2024 22:01:05 +0100 Subject: [PATCH] [GITEA] Fix test `TestWebhookProxy` with http proxy env - Unset the http proxies environments for the `TestWebhookProxy`. - Resolves #2132 --- services/webhook/deliver_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/webhook/deliver_test.go b/services/webhook/deliver_test.go index 72aa00478a..eca2ba244b 100644 --- a/services/webhook/deliver_test.go +++ b/services/webhook/deliver_test.go @@ -8,6 +8,7 @@ import ( "net/http" "net/http/httptest" "net/url" + "os" "testing" "time" @@ -25,9 +26,15 @@ import ( func TestWebhookProxy(t *testing.T) { oldWebhook := setting.Webhook + oldHTTPProxy := os.Getenv("http_proxy") + oldHTTPSProxy := os.Getenv("https_proxy") t.Cleanup(func() { setting.Webhook = oldWebhook + os.Setenv("http_proxy", oldHTTPProxy) + os.Setenv("https_proxy", oldHTTPSProxy) }) + os.Unsetenv("http_proxy") + os.Unsetenv("https_proxy") setting.Webhook.ProxyURL = "http://localhost:8080" setting.Webhook.ProxyURLFixed, _ = url.Parse(setting.Webhook.ProxyURL)