Browse code

Fixes 2 panics initialising tests

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/09/04 06:27:53
Showing 1 changed files
... ...
@@ -502,10 +502,9 @@ func init() {
502 502
 	// Obtain the daemon platform so that it can be used by tests to make
503 503
 	// intelligent decisions about how to configure themselves, and validate
504 504
 	// that the target platform is valid.
505
-	res, b, err := sockRequestRaw("GET", "/version", nil, "application/json")
506
-	defer b.Close()
507
-	if err != nil || res.StatusCode != http.StatusOK {
508
-		panic("Init failed to get version: " + err.Error() + " " + string(res.StatusCode))
505
+	res, _, err := sockRequestRaw("GET", "/version", nil, "application/json")
506
+	if err != nil || res == nil || (res != nil && res.StatusCode != http.StatusOK) {
507
+		panic(fmt.Errorf("Init failed to get version: %v. Res=%v", err.Error(), res))
509 508
 	}
510 509
 	svrHeader, _ := httputils.ParseServerHeader(res.Header.Get("Server"))
511 510
 	daemonPlatform = svrHeader.OS