1
0
mirror of https://github.com/astaxie/beego.git synced 2024-05-29 06:13:28 +00:00
Beego/httplib_test.go

33 lines
504 B
Go
Raw Normal View History

2013-08-03 14:20:09 +00:00
package beego
import (
"io/ioutil"
"testing"
)
func TestGetUrl(t *testing.T) {
resp, err := GetUrl("http://beego.me/").Response()
if err != nil {
t.Fatal(err)
}
if resp.Body == nil {
t.Fatal("body is nil")
}
data, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
t.Fatal(err)
}
if len(data) == 0 {
t.Fatal("data is no")
}
str, err := GetUrl("http://beego.me/").String()
if err != nil {
t.Fatal(err)
}
if len(str) == 0 {
t.Fatal("has no info")
}
}