Merge pull request '[GITEA] Fix test TestWebhookProxy with http proxy env' (#2137) from gusted/forgejo-webhook into forgejo-dependency

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2137
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-01-14 19:14:12 +00:00
commit 53dc31bda2

View file

@ -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)