github.com/icexin/eggos@v0.4.2-0.20220216025428-78b167e4f349/tests/net_test.go (about) 1 package tests 2 3 import ( 4 "net" 5 "net/http" 6 "testing" 7 8 _ "github.com/icexin/eggos" 9 ) 10 11 func TestHTTP(t *testing.T) { 12 server := http.Server{} 13 14 listener, err := net.Listen("tcp", ":80") 15 if err != nil { 16 t.Fatal(err) 17 } 18 defer listener.Close() 19 20 go server.Serve(listener) 21 22 resp, err := http.Get("http://10.0.2.15") 23 if err != nil { 24 t.Error(err) 25 return 26 } 27 resp.Body.Close() 28 }