blob: e5de8d029a9962a90e9af5425ea1120f5ddb3cc0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// SPDX-License-Identifier: CC0-1.0
package pipeln
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test(t *testing.T) {
ln := New("test:80")
mux := http.NewServeMux()
mux.HandleFunc("/endpoint", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
})
srv := http.Server{Handler: mux}
go srv.Serve(ln)
client := http.Client{Transport: &http.Transport{Dial: ln.Dial}}
resp, err := client.Get("http://test/endpoint")
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
srv.Shutdown(context.Background())
}
|