Skip to content

Commit

Permalink
correct variables
Browse files Browse the repository at this point in the history
  • Loading branch information
eshitachandwani committed Nov 25, 2024
1 parent 3b82bed commit 445664c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions internal/resolver/delegatingresolver/delegatingresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,19 @@ func createTestResolverClientConn(t *testing.T) (*testutils.ResolverClientConn,
return tcc, stateCh, errCh
}

// overwriteAndRestoreProxyEnv overwrite HTTPS_PROXY enviornment and

Check failure on line 98 in internal/resolver/delegatingresolver/delegatingresolver_test.go

View workflow job for this annotation

GitHub Actions / tests (vet, 1.22)

"enviornment" is a misspelling of "environment"

Check failure on line 98 in internal/resolver/delegatingresolver/delegatingresolver_test.go

View workflow job for this annotation

GitHub Actions / tests (vet, 1.22)

"enviornment" is a misspelling of "environment"
// returns a function to restore the default values.
func overwriteAndRestoreProxyEnv(proxyURI string) func() {
origHTTPSProxy := envconfig.HTTPSProxy
envconfig.HTTPSProxy = proxyURI
return func() { envconfig.HTTPSProxy = origHTTPSProxy }
}

// TestDelegatingResolverNoProxy verifies the behavior of the delegating resolver
// when no proxy is configured.
func (s) TestDelegatingResolverNoProxy(t *testing.T) {
// Enable HTTP Proxy env var.
origHTTPProxy := envconfig.HTTPProxy
envconfig.HTTPProxy = ""
defer func() { envconfig.HTTPProxy = origHTTPProxy }()
defer overwriteAndRestoreProxyEnv("")()
mr := manual.NewBuilderWithScheme("test") // Set up a manual resolver to control the address resolution.
target := "test:///" + targetTestAddr
tcc, stateCh, _ := createTestResolverClientConn(t)
Expand Down Expand Up @@ -148,9 +154,7 @@ func setupDNS(t *testing.T) *manual.Resolver {
// configured and target resolution is enabled.
func (s) TestDelegatingResolverwithDNSAndProxyWithTargetResolution(t *testing.T) {
// Enable HTTP Proxy env var.
origHTTPProxy := envconfig.HTTPProxy
envconfig.HTTPProxy = "testProxyAddr.com"
defer func() { envconfig.HTTPProxy = origHTTPProxy }()
defer overwriteAndRestoreProxyEnv(envProxyAddr)()
hpfe := func(req *http.Request) (*url.URL, error) {
if req.URL.Host == targetTestAddr {
return &url.URL{
Expand Down Expand Up @@ -201,9 +205,8 @@ func (s) TestDelegatingResolverwithDNSAndProxyWithTargetResolution(t *testing.T)
// configured.
func (s) TestDelegatingResolverwithDNSAndProxyWithNoTargetResolution(t *testing.T) {
// Enable HTTP Proxy env var.
origHTTPProxy := envconfig.HTTPProxy
envconfig.HTTPProxy = "testProxyAddr.com"
defer func() { envconfig.HTTPProxy = origHTTPProxy }()
defer overwriteAndRestoreProxyEnv(envProxyAddr)()

hpfe := func(req *http.Request) (*url.URL, error) {
if req.URL.Host == targetTestAddr {
return &url.URL{
Expand Down Expand Up @@ -248,9 +251,7 @@ func (s) TestDelegatingResolverwithDNSAndProxyWithNoTargetResolution(t *testing.
// configured.
func (s) TestDelegatingResolverwithCustomResolverAndProxy(t *testing.T) {
// Enable HTTP Proxy env var.
origHTTPProxy := envconfig.HTTPProxy
envconfig.HTTPProxy = "testProxyAddr.com"
defer func() { envconfig.HTTPProxy = origHTTPProxy }()
defer overwriteAndRestoreProxyEnv(envProxyAddr)()
hpfe := func(req *http.Request) (*url.URL, error) {
if req.URL.Host == targetTestAddr {
return &url.URL{
Expand Down

0 comments on commit 445664c

Please sign in to comment.