changed testRouter() signature

This commit is contained in:
Pedro Nasser
2016-07-31 22:37:39 -03:00
parent 0af48a897b
commit 5986777f2a
3 changed files with 25 additions and 11 deletions

View File

@@ -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

View File

@@ -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{})

View File

@@ -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