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:
parent
05c8932166
commit
189853de32
|
@ -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()
|
||||
}
|
Loading…
Reference in a new issue