Beispiel #1
0
func TestHelloWorld(t *testing.T) {
	request := beetest.Get("/ping")
	response, _ := request.Response()
	defer response.Body.Close()
	contents, _ := ioutil.ReadAll(response.Body)
	if string(contents) != "pong" {
		t.Errorf("response sould be pong")
	}
}
Beispiel #2
0
func TestExpand(t *testing.T) {
	request := beetest.Get("/v1/expand")
	request.Param("shorturl", "5laZF")
	response, _ := request.Response()
	defer response.Body.Close()
	contents, _ := ioutil.ReadAll(response.Body)
	var s ShortResult
	json.Unmarshal(contents, &s)
	if s.UrlLong == "" {
		t.Fatal("urllong is empty")
	}
}
Beispiel #3
0
// TestMain is a sample to run an endpoint test
func TestMain(t *testing.T) {
	request := httplib.Get("/user/get")
	request.Param("id", "1")
	response, _ := request.Response()
	//	defer response.Body.Close()
	contents, _ := ioutil.ReadAll(response.Body)
	log.Fatalln(fmt.Sprintf("%v", string(contents)))
	//	var s ShortResult
	//	json.Unmarshal(contents, &s)
	//	if s.UrlLong == "" {
	//		t.Fatal("urllong is empty")
	//	}

}