github.com/jspc/eggos@v0.5.1-0.20221028160421-556c75c878a5/tests/net_test.go (about)

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