github.com/wangyougui/gf/v2@v2.6.5/frame/gins/gins_z_unit_httpclient_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package gins_test
     8  
     9  import (
    10  	"fmt"
    11  	"testing"
    12  
    13  	"github.com/wangyougui/gf/v2/frame/gins"
    14  	"github.com/wangyougui/gf/v2/test/gtest"
    15  )
    16  
    17  func Test_Client(t *testing.T) {
    18  	gtest.C(t, func(t *gtest.T) {
    19  		var (
    20  			c  = gins.HttpClient()
    21  			c1 = gins.HttpClient("c1")
    22  			c2 = gins.HttpClient("c2")
    23  		)
    24  		c.SetAgent("test1")
    25  		c.SetAgent("test2")
    26  		t.AssertNE(fmt.Sprintf(`%p`, c), fmt.Sprintf(`%p`, c1))
    27  		t.AssertNE(fmt.Sprintf(`%p`, c), fmt.Sprintf(`%p`, c2))
    28  		t.AssertNE(fmt.Sprintf(`%p`, c1), fmt.Sprintf(`%p`, c2))
    29  	})
    30  }