diff --git a/api/server/router/apps_test.go b/api/server/router/apps_test.go index f7c7f4aca..3ba2a714d 100644 --- a/api/server/router/apps_test.go +++ b/api/server/router/apps_test.go @@ -7,10 +7,11 @@ import ( "testing" "github.com/iron-io/functions/api/models" + "github.com/iron-io/functions/api/server/datastore" ) func TestAppCreate(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -50,7 +51,7 @@ func TestAppCreate(t *testing.T) { } func TestAppDelete(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -80,7 +81,7 @@ func TestAppDelete(t *testing.T) { } func TestAppList(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -109,7 +110,7 @@ func TestAppList(t *testing.T) { } func TestAppGet(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -138,7 +139,7 @@ func TestAppGet(t *testing.T) { } func TestAppUpdate(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string diff --git a/api/server/router/helpers.go b/api/server/router/helpers.go index ce4a0ef32..0f44010ee 100644 --- a/api/server/router/helpers.go +++ b/api/server/router/helpers.go @@ -14,7 +14,19 @@ import ( "github.com/iron-io/functions/api/server/datastore" ) -func testRouter() *gin.Engine { +func testRouter(ds models.Datastore, config *models.Config) *gin.Engine { + r := gin.Default() + r.Use(func(c *gin.Context) { + c.Set("store", ds) + c.Set("log", logrus.WithFields(logrus.Fields{})) + c.Set("config", config) + c.Next() + }) + Start(r) + return r +} + +func testRouterWithDefault() *gin.Engine { r := gin.Default() r.Use(func(c *gin.Context) { c.Set("store", &datastore.Mock{}) diff --git a/api/server/router/routes_test.go b/api/server/router/routes_test.go index 7d5e6d091..37192b025 100644 --- a/api/server/router/routes_test.go +++ b/api/server/router/routes_test.go @@ -7,10 +7,11 @@ import ( "testing" "github.com/iron-io/functions/api/models" + "github.com/iron-io/functions/api/server/datastore" ) func TestRouteCreate(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -51,7 +52,7 @@ func TestRouteCreate(t *testing.T) { } func TestRouteDelete(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -81,7 +82,7 @@ func TestRouteDelete(t *testing.T) { } func TestRouteList(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -110,7 +111,7 @@ func TestRouteList(t *testing.T) { } func TestRouteGet(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string @@ -139,7 +140,7 @@ func TestRouteGet(t *testing.T) { } func TestRouteUpdate(t *testing.T) { - router := testRouter() + router := testRouter(&datastore.Mock{}, &models.Config{}) for i, test := range []struct { path string