diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2021-02-13 18:03:27 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2021-02-13 18:03:27 +0000 |
| commit | fcc1f852131a7eaf026f172cd54ce6db3b79bc04 (patch) | |
| tree | 57de99ac32d4cc8d8cd63c195d4f42fab6829956 /pipeln_test.go | |
| parent | 7f63cc1008f96ff1d29e9b3bf3f343b3009a4551 (diff) | |
First basic version that works
Diffstat (limited to 'pipeln_test.go')
| -rw-r--r-- | pipeln_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
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()) +} |
