diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-11 22:57:40 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-11 22:57:40 +0700 |
| commit | 1eb846cb1e17132ae9c1756ccfbb0e422957bc7b (patch) | |
| tree | c07edc45ad69c421773f7529b2187d6b898f0557 | |
| parent | 95622f8904b8448f97e46a55b2da2273f511a8b8 (diff) | |
| download | rescached-1eb846cb1e17132ae9c1756ccfbb0e422957bc7b.tar.xz | |
test: wait for server before running the test
On build.kilabit.info, 2 out 5 building this repository return an error
dial tcp 127.0.0.1:5381: connect: connection refused
This is due to server is not ready accepting connection while the test
for client is already running.
| -rw-r--r-- | rescached_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/rescached_test.go b/rescached_test.go index ebf480f..6ec38e8 100644 --- a/rescached_test.go +++ b/rescached_test.go @@ -7,6 +7,7 @@ import ( "log" "os" "testing" + "time" libhttp "github.com/shuLhan/share/lib/http" ) @@ -25,6 +26,7 @@ func TestMain(m *testing.M) { var ( err error testStatus int + x int ) go mockBlockdServer() @@ -48,6 +50,16 @@ func TestMain(m *testing.M) { resc = NewClient("http://"+testEnv.WUIListen, false) + // Loop 10 times until server ready for testing. + for x = 0; x < 10; x++ { + time.Sleep(500) + _, err = resc.Env() + if err != nil { + continue + } + break + } + testStatus = m.Run() os.Exit(testStatus) |
