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

@@ -36,8 +36,7 @@ func TestRouteCreate(t *testing.T) {
// success
{&datastore.Mock{}, "/v1/apps/a/routes", `{ "route": { "image": "iron/hello", "path": "/myroute" } }`, 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)
@@ -65,8 +64,7 @@ func TestRouteDelete(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
@@ -102,8 +100,7 @@ func TestRouteList(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
@@ -138,8 +135,7 @@ func TestRouteGet(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
@@ -174,8 +170,7 @@ func TestRouteUpdate(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