diff options
-rw-r--r-- | service/http/service_test.go | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/service/http/service_test.go b/service/http/service_test.go index a1aecd24..2bb4b905 100644 --- a/service/http/service_test.go +++ b/service/http/service_test.go @@ -176,7 +176,7 @@ func Test_Service_Env(t *testing.T) { assert.NoError(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6031", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, @@ -206,10 +206,10 @@ func Test_Service_Env(t *testing.T) { t.Errorf("serve error: %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() - req, err := http.NewRequest("GET", "http://localhost:6029", nil) + time.Sleep(time.Second * 1) + + req, err := http.NewRequest("GET", "http://localhost:6031", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -227,6 +227,7 @@ func Test_Service_Env(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 200, r.StatusCode) assert.Equal(t, "ENV_VALUE", string(b)) + c.Stop() } func Test_Service_ErrorEcho(t *testing.T) { @@ -238,7 +239,7 @@ func Test_Service_ErrorEcho(t *testing.T) { assert.NoError(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6030", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, @@ -274,10 +275,10 @@ func Test_Service_ErrorEcho(t *testing.T) { t.Errorf("serve error: %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() - req, err := http.NewRequest("GET", "http://localhost:6029?hello=world", nil) + time.Sleep(time.Second) + + req, err := http.NewRequest("GET", "http://localhost:6030?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -297,6 +298,7 @@ func Test_Service_ErrorEcho(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 201, r.StatusCode) assert.Equal(t, "WORLD", string(b)) + c.Stop() } func Test_Service_Middleware(t *testing.T) { @@ -308,7 +310,7 @@ func Test_Service_Middleware(t *testing.T) { assert.NoError(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6032", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, @@ -352,7 +354,7 @@ func Test_Service_Middleware(t *testing.T) { time.Sleep(time.Millisecond * 100) defer c.Stop() - req, err := http.NewRequest("GET", "http://localhost:6029?hello=world", nil) + req, err := http.NewRequest("GET", "http://localhost:6032?hello=world", nil) assert.NoError(t, err) r, err := http.DefaultClient.Do(req) @@ -370,7 +372,7 @@ func Test_Service_Middleware(t *testing.T) { t.Errorf("error closing the Body: error %v", err) } - req, err = http.NewRequest("GET", "http://localhost:6029/halt", nil) + req, err = http.NewRequest("GET", "http://localhost:6032/halt", nil) assert.NoError(t, err) r, err = http.DefaultClient.Do(req) @@ -397,7 +399,7 @@ func Test_Service_Listener(t *testing.T) { assert.NoError(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6033", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, @@ -446,7 +448,7 @@ func Test_Service_Error(t *testing.T) { assert.NoError(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6034", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, @@ -475,7 +477,7 @@ func Test_Service_Error2(t *testing.T) { assert.NoError(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6035", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, @@ -504,7 +506,7 @@ func Test_Service_Error3(t *testing.T) { assert.Error(t, c.Init(&testCfg{httpCfg: `{ "enable": true, - "address": ":6029", + "address": ":6036", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, |