server.New signature changes and test fixes. (#324)

* ctx middleware should always be the first added to router

* plugable enqueue func, changed server.New signature

* fix tests

* remove ctx/ctx.Done from server
This commit is contained in:
Pedro Nasser
2016-11-21 14:11:01 -02:00
committed by C Cirello
parent bc0f0c8b42
commit 0343c4990c
9 changed files with 52 additions and 58 deletions

View File

@@ -57,8 +57,7 @@ func TestAppCreate(t *testing.T) {
// success
{&datastore.Mock{}, "/v1/apps", `{ "app": { "name": "teste" } }`, http.StatusCreated, nil},
} {
s := New(test.mock, &mqs.Mock{}, testRunner(t), tasks)
router := testRouter(s)
router := testRouter(test.mock, &mqs.Mock{}, testRunner(t), tasks)
body := bytes.NewBuffer([]byte(test.body))
_, rec := routerRequest(t, router, "POST", test.path, body)
@@ -86,8 +85,7 @@ func TestAppDelete(t *testing.T) {
tasks := mockTasksConduit()
defer close(tasks)
s := New(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
router := testRouter(s)
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
for i, test := range []struct {
path string
@@ -123,8 +121,7 @@ func TestAppList(t *testing.T) {
tasks := mockTasksConduit()
defer close(tasks)
s := New(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
router := testRouter(s)
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
for i, test := range []struct {
path string
@@ -159,8 +156,7 @@ func TestAppGet(t *testing.T) {
tasks := mockTasksConduit()
defer close(tasks)
s := New(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
router := testRouter(s)
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
for i, test := range []struct {
path string
@@ -212,8 +208,7 @@ func TestAppUpdate(t *testing.T) {
},
}, "/v1/apps/myapp", `{ "app": { "config": { "test": "1" } } }`, http.StatusOK, nil},
} {
s := New(test.mock, &mqs.Mock{}, testRunner(t), tasks)
router := testRouter(s)
router := testRouter(test.mock, &mqs.Mock{}, testRunner(t), tasks)
body := bytes.NewBuffer([]byte(test.body))
_, rec := routerRequest(t, router, "PUT", test.path, body)