fix : Failed to request test list when excepting status code 200

This commit is contained in:
yuki2006
2015-11-23 02:46:03 +09:00
parent 8a7b1a81ac
commit b2ec002b4d

View File

@@ -3,9 +3,9 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/revel/revel"
"github.com/revel/cmd/harness" "github.com/revel/cmd/harness"
"github.com/revel/modules/testrunner/app/controllers" "github.com/revel/modules/testrunner/app/controllers"
"github.com/revel/revel"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@@ -117,13 +117,19 @@ You can add it to a run mode configuration with the following line:
) )
for i := 0; ; i++ { for i := 0; ; i++ {
if resp, err = http.Get(baseUrl + "/@tests.list"); err == nil { if resp, err = http.Get(baseUrl + "/@tests.list"); err == nil {
if resp.StatusCode == 200 {
break break
} }
}
if i < 3 { if i < 3 {
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
continue continue
} }
if err != nil {
errorf("Failed to request test list: %s", err) errorf("Failed to request test list: %s", err)
} else {
errorf("Failed to request test list: Not status code 200")
}
} }
defer resp.Body.Close() defer resp.Body.Close()
json.NewDecoder(resp.Body).Decode(&testSuites) json.NewDecoder(resp.Body).Decode(&testSuites)