From 5134446c3faf89b90b8a2dc35b6f5e3dcabb6d63 Mon Sep 17 00:00:00 2001 From: liwei Date: Tue, 30 Apr 2024 17:38:29 +0800 Subject: [PATCH] fix: test --- internal/protocol/bt/fetcher_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/protocol/bt/fetcher_test.go b/internal/protocol/bt/fetcher_test.go index 09f3d483..751f9f85 100644 --- a/internal/protocol/bt/fetcher_test.go +++ b/internal/protocol/bt/fetcher_test.go @@ -8,8 +8,6 @@ import ( "github.com/GopeedLab/gopeed/internal/test" "github.com/GopeedLab/gopeed/pkg/base" "github.com/GopeedLab/gopeed/pkg/protocol/bt" - "github.com/GopeedLab/gopeed/pkg/util" - "net/url" "os" "reflect" "testing" @@ -60,7 +58,14 @@ func TestFetcher_ResolveWithProxy(t *testing.T) { proxyListener := test.StartSocks5Server(usr, pwd) defer proxyListener.Close() - doResolve(t, buildConfigFetcher(util.BuildProxyUrl("socks5", proxyListener.Addr().String(), usr, pwd))) + doResolve(t, buildConfigFetcher(&base.DownloaderProxyConfig{ + Enable: true, + System: false, + Scheme: "socks5", + Host: proxyListener.Addr().String(), + Usr: usr, + Pwd: pwd, + })) } func doResolve(t *testing.T, fetcher fetcher.Fetcher) { @@ -100,7 +105,7 @@ func buildFetcher() fetcher.Fetcher { return fetcher } -func buildConfigFetcher(proxyUrl *url.URL) fetcher.Fetcher { +func buildConfigFetcher(proxyConfig *base.DownloaderProxyConfig) fetcher.Fetcher { fetcher := new(FetcherBuilder).Build() newController := controller.NewController() mockCfg := config{ @@ -114,7 +119,7 @@ func buildConfigFetcher(proxyUrl *url.URL) fetcher.Fetcher { } return true } - newController.ToUrl = proxyUrl + newController.ProxyConfig = proxyConfig fetcher.Setup(newController) return fetcher }