mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
changed testRouter() signature
This commit is contained in:
@@ -7,10 +7,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/iron-io/functions/api/models"
|
"github.com/iron-io/functions/api/models"
|
||||||
|
"github.com/iron-io/functions/api/server/datastore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAppCreate(t *testing.T) {
|
func TestAppCreate(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -50,7 +51,7 @@ func TestAppCreate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppDelete(t *testing.T) {
|
func TestAppDelete(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -80,7 +81,7 @@ func TestAppDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppList(t *testing.T) {
|
func TestAppList(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -109,7 +110,7 @@ func TestAppList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppGet(t *testing.T) {
|
func TestAppGet(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -138,7 +139,7 @@ func TestAppGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppUpdate(t *testing.T) {
|
func TestAppUpdate(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
|
|||||||
@@ -14,7 +14,19 @@ import (
|
|||||||
"github.com/iron-io/functions/api/server/datastore"
|
"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 := gin.Default()
|
||||||
r.Use(func(c *gin.Context) {
|
r.Use(func(c *gin.Context) {
|
||||||
c.Set("store", &datastore.Mock{})
|
c.Set("store", &datastore.Mock{})
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/iron-io/functions/api/models"
|
"github.com/iron-io/functions/api/models"
|
||||||
|
"github.com/iron-io/functions/api/server/datastore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRouteCreate(t *testing.T) {
|
func TestRouteCreate(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -51,7 +52,7 @@ func TestRouteCreate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteDelete(t *testing.T) {
|
func TestRouteDelete(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -81,7 +82,7 @@ func TestRouteDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteList(t *testing.T) {
|
func TestRouteList(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -110,7 +111,7 @@ func TestRouteList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteGet(t *testing.T) {
|
func TestRouteGet(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
@@ -139,7 +140,7 @@ func TestRouteGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteUpdate(t *testing.T) {
|
func TestRouteUpdate(t *testing.T) {
|
||||||
router := testRouter()
|
router := testRouter(&datastore.Mock{}, &models.Config{})
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
path string
|
path string
|
||||||
|
|||||||
Reference in New Issue
Block a user