Error types
// DumbGetter will get the string body of url if it gets a 200
func DumbGetter(url string) (string, error) {
res, err := http.Get(url)
if err != nil {
return "", fmt.Errorf("problem fetching from %s, %v", url, err)
}
if res.StatusCode != http.StatusOK {
return "", fmt.Errorf("did not get 200 from %s, got %d", url, res.StatusCode)
}
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body) // ignoring err for brevity
return string(body), nil
}이 테스트 방법의 문제점
우리가 해야하는 것
이 테스트는 무엇을 할까?
정리
보충
Last updated