Reject async requests in case if MQ is not reachable

This commit is contained in:
Denis Makogon
2017-07-25 10:03:04 -07:00
committed by Reed Allman
parent 565f61fe6f
commit 97b0b97bd8
5 changed files with 64 additions and 18 deletions

View File

@@ -48,7 +48,7 @@ func TestAppCreate(t *testing.T) {
{datastore.NewMock(), logs.NewMock(), "/v1/apps", `{ "app": { "name": "teste" } }`, http.StatusOK, nil},
} {
rnr, cancel := testRunner(t)
srv := testServer(test.mock, &mqs.Mock{}, test.logDB, rnr)
srv := testServer(test.mock, &mqs.Mock{}, test.logDB, rnr, DefaultEnqueue)
router := srv.Router
body := bytes.NewBuffer([]byte(test.body))
@@ -92,7 +92,7 @@ func TestAppDelete(t *testing.T) {
), logs.NewMock(), "/v1/apps/myapp", "", http.StatusOK, nil},
} {
rnr, cancel := testRunner(t)
srv := testServer(test.ds, &mqs.Mock{}, test.logDB, rnr)
srv := testServer(test.ds, &mqs.Mock{}, test.logDB, rnr, DefaultEnqueue)
_, rec := routerRequest(t, srv.Router, "DELETE", test.path, nil)
@@ -122,7 +122,7 @@ func TestAppList(t *testing.T) {
defer cancel()
ds := datastore.NewMock()
fnl := logs.NewMock()
srv := testServer(ds, &mqs.Mock{}, fnl, rnr)
srv := testServer(ds, &mqs.Mock{}, fnl, rnr, DefaultEnqueue)
for i, test := range []struct {
path string
@@ -159,7 +159,7 @@ func TestAppGet(t *testing.T) {
defer cancel()
ds := datastore.NewMock()
fnl := logs.NewMock()
srv := testServer(ds, &mqs.Mock{}, fnl, rnr)
srv := testServer(ds, &mqs.Mock{}, fnl, rnr, DefaultEnqueue)
for i, test := range []struct {
path string
@@ -218,7 +218,7 @@ func TestAppUpdate(t *testing.T) {
), logs.NewMock(), "/v1/apps/myapp", `{ "app": { "name": "othername" } }`, http.StatusConflict, nil},
} {
rnr, cancel := testRunner(t)
srv := testServer(test.mock, &mqs.Mock{}, test.logDB, rnr)
srv := testServer(test.mock, &mqs.Mock{}, test.logDB, rnr, DefaultEnqueue)
body := bytes.NewBuffer([]byte(test.body))
_, rec := routerRequest(t, srv.Router, "PATCH", test.path, body)