github.com/searKing/golang/go@v1.2.117/net/http/httpproxy/proxy_test.go (about) 1 // Copyright 2022 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package httpproxy_test 6 7 import ( 8 "context" 9 "testing" 10 11 "github.com/searKing/golang/go/net/http/httpproxy" 12 ) 13 14 func TestWithProxy(t *testing.T) { 15 ctx := context.Background() 16 want := &httpproxy.Proxy{ 17 ProxyUrl: "socks5://127.0.0.1:8080", 18 ProxyTarget: "dns:///want.example.com", 19 } 20 ctx = httpproxy.WithProxy(ctx, want) 21 got := httpproxy.ContextProxy(ctx) 22 if got == nil || got.ProxyUrl != want.ProxyUrl || got.ProxyTarget != want.ProxyTarget { 23 t.Errorf("got %v; want %v", got, want) 24 } 25 }