1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 18:31:28 +00:00
Beego/httplib/httplib_test.go
2014-04-12 13:18:18 +08:00

39 lines
822 B
Go

// Beego (http://beego.me/)
// @description beego is an open-source, high-performance web framework for the Go programming language.
// @link http://github.com/astaxie/beego for the canonical source repository
// @license http://github.com/astaxie/beego/blob/master/LICENSE
// @authors astaxie
package httplib
import (
"io/ioutil"
"testing"
)
func TestGetUrl(t *testing.T) {
resp, err := Get("http://beego.me/").Debug(true).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 := Get("http://beego.me/").String()
if err != nil {
t.Fatal(err)
}
if len(str) == 0 {
t.Fatal("has no info")
}
}