github.com/searKing/golang/go@v1.2.117/net/http/httphost/host_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 httphost_test
     6  
     7  import (
     8  	"context"
     9  	"testing"
    10  
    11  	"github.com/searKing/golang/go/net/http/httphost"
    12  )
    13  
    14  func TestWithProxy(t *testing.T) {
    15  	ctx := context.Background()
    16  	want := &httphost.Host{
    17  		HostTarget: "dns:///want.example.com",
    18  	}
    19  	ctx = httphost.WithHost(ctx, want)
    20  	got := httphost.ContextHost(ctx)
    21  	if got == nil || got.HostTarget != want.HostTarget {
    22  		t.Errorf("got %v; want %v", got, want)
    23  	}
    24  }