github.com/gospider007/requests@v0.0.0-20240506025355-c73d46169a23/test/session_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/gospider007/requests" 7 ) 8 9 func TestSession(t *testing.T) { 10 session, _ := requests.NewClient(nil) 11 for i := 0; i < 2; i++ { 12 resp, err := session.Get(nil, "https://httpbin.org/anything") 13 if err != nil { 14 t.Error(err) 15 } 16 if i == 0 { 17 if !resp.IsNewConn() { //return is NewConn 18 t.Error("new conn error: ", i) 19 } 20 } else { 21 if resp.IsNewConn() { 22 t.Error("new conn error: ", i) 23 } 24 } 25 } 26 }