diff --git a/inkio/net.go b/inkio/net.go index d847c6e..57af5c0 100644 --- a/inkio/net.go +++ b/inkio/net.go @@ -25,7 +25,7 @@ func GetRequest(templateURL string) (string, error) { } defer resp.Body.Close() if resp.StatusCode != 200 { - return emptystring, fmt.Errorf("%s returned a non-200 response status code value %d", templateURL, resp.StatusCode) + return emptystring, fmt.Errorf("%s returned a non-200 response status: %s", templateURL, resp.Status) } body, _ := ioutil.ReadAll(resp.Body) diff --git a/inkio/net_test.go b/inkio/net_test.go index 3474d17..fca4d39 100644 --- a/inkio/net_test.go +++ b/inkio/net_test.go @@ -1,6 +1,10 @@ package inkio -import "testing" +import ( + "fmt" + "strings" + "testing" +) func TestGetRequestValidURL(t *testing.T) { responsePointer, err := GetRequest("https://raw.githubusercontent.com/chrissimpkins/ink/master/testfiles/simpletext.txt") @@ -20,4 +24,7 @@ func TestGetRequestInvalidURL(t *testing.T) { if err == nil { t.Errorf("[FAIL] GetRequest function should have returned an error on an invalid URL, instead returned nil") } + if strings.Contains(fmt.Sprint(err), "404 Not Found") == false { + t.Errorf("[FAIL] GetRequest function should have returned 404 response status code on invalid URL to missing file") + } }