1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-18 04:42:54 +00:00

Removed test for removed function

This commit is contained in:
diamondburned (Forefront) 2020-01-18 19:15:23 -08:00
parent 05c8932166
commit 189853de32

View file

@ -1,63 +0,0 @@
package httputil
import (
"io"
"io/ioutil"
"net"
"net/http"
"testing"
)
func TestMeanwhileBody(t *testing.T) {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
b, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatal("Can't read body:", err)
}
if s := string(b); s != "Hime" {
t.Fatal("Unexpected body:", s)
}
w.Write([]byte("Arikawa"))
})
addr := startHTTP(t)
c := NewClient()
w := func(w io.Writer) error {
w.Write([]byte("Hime"))
return nil
}
r, err := c.MeanwhileBody(w, "GET", "http://"+addr)
if err != nil {
t.Fatal("Failed to send request:", err)
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatal("Can't read body:", err)
}
if s := string(b); s != "Arikawa" {
t.Fatal("Unexpected body:", s)
}
}
func startHTTP(t *testing.T) string {
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal("TCP error:", err)
}
go func() {
if err := http.Serve(listener, nil); err != nil {
t.Fatal("HTTP error:", err)
}
}()
return listener.Addr().(*net.TCPAddr).String()
}