From fcc1f852131a7eaf026f172cd54ce6db3b79bc04 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sat, 13 Feb 2021 18:03:27 +0000 Subject: First basic version that works --- pipeln_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 pipeln_test.go (limited to 'pipeln_test.go') diff --git a/pipeln_test.go b/pipeln_test.go new file mode 100644 index 0000000..e5de8d0 --- /dev/null +++ b/pipeln_test.go @@ -0,0 +1,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()) +} -- cgit v1.2.3-70-g09d2