mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
remove unnecessary config
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRouteCreate(t *testing.T) {
|
func TestRouteCreate(t *testing.T) {
|
||||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
New(&datastore.Mock{}, testRunner(t))
|
||||||
router := testRouter()
|
router := testRouter()
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
@@ -52,7 +52,7 @@ func TestRouteCreate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteDelete(t *testing.T) {
|
func TestRouteDelete(t *testing.T) {
|
||||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
New(&datastore.Mock{}, testRunner(t))
|
||||||
router := testRouter()
|
router := testRouter()
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
@@ -83,7 +83,7 @@ func TestRouteDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteList(t *testing.T) {
|
func TestRouteList(t *testing.T) {
|
||||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
New(&datastore.Mock{}, testRunner(t))
|
||||||
router := testRouter()
|
router := testRouter()
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
@@ -113,7 +113,7 @@ func TestRouteList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteGet(t *testing.T) {
|
func TestRouteGet(t *testing.T) {
|
||||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
New(&datastore.Mock{}, testRunner(t))
|
||||||
router := testRouter()
|
router := testRouter()
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
@@ -143,7 +143,7 @@ func TestRouteGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRouteUpdate(t *testing.T) {
|
func TestRouteUpdate(t *testing.T) {
|
||||||
New(&models.Config{}, &datastore.Mock{}, testRunner(t))
|
New(&datastore.Mock{}, testRunner(t))
|
||||||
router := testRouter()
|
router := testRouter()
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
|
|||||||
@@ -20,16 +20,14 @@ var Api *Server
|
|||||||
type Server struct {
|
type Server struct {
|
||||||
Runner *runner.Runner
|
Runner *runner.Runner
|
||||||
Router *gin.Engine
|
Router *gin.Engine
|
||||||
Config *models.Config
|
|
||||||
Datastore models.Datastore
|
Datastore models.Datastore
|
||||||
AppListeners []ifaces.AppListener
|
AppListeners []ifaces.AppListener
|
||||||
SpecialHandlers []ifaces.SpecialHandler
|
SpecialHandlers []ifaces.SpecialHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(c *models.Config, ds models.Datastore, r *runner.Runner) *Server {
|
func New(ds models.Datastore, r *runner.Runner) *Server {
|
||||||
Api = &Server{
|
Api = &Server{
|
||||||
Router: gin.Default(),
|
Router: gin.Default(),
|
||||||
Config: c,
|
|
||||||
Datastore: ds,
|
Datastore: ds,
|
||||||
Runner: r,
|
Runner: r,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func TestFullStack(t *testing.T) {
|
|||||||
ds, close := prepareBolt(t)
|
ds, close := prepareBolt(t)
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
New(&models.Config{}, ds, testRunner(t))
|
New(ds, testRunner(t))
|
||||||
router := testRouter()
|
router := testRouter()
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
|
|||||||
9
main.go
9
main.go
@@ -4,7 +4,6 @@ import (
|
|||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/iron-io/functions/api/config"
|
"github.com/iron-io/functions/api/config"
|
||||||
"github.com/iron-io/functions/api/datastore"
|
"github.com/iron-io/functions/api/datastore"
|
||||||
"github.com/iron-io/functions/api/models"
|
|
||||||
"github.com/iron-io/functions/api/runner"
|
"github.com/iron-io/functions/api/runner"
|
||||||
"github.com/iron-io/functions/api/server"
|
"github.com/iron-io/functions/api/server"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -13,15 +12,9 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
c := &models.Config{}
|
|
||||||
|
|
||||||
config.InitConfig()
|
config.InitConfig()
|
||||||
|
|
||||||
err := c.Validate()
|
|
||||||
if err != nil {
|
|
||||||
log.WithError(err).Fatalln("Invalid config.")
|
|
||||||
}
|
|
||||||
|
|
||||||
ds, err := datastore.New(viper.GetString("DB"))
|
ds, err := datastore.New(viper.GetString("DB"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalln("Invalid DB url.")
|
log.WithError(err).Fatalln("Invalid DB url.")
|
||||||
@@ -32,6 +25,6 @@ func main() {
|
|||||||
log.WithError(err).Fatalln("Failed to create a runner")
|
log.WithError(err).Fatalln("Failed to create a runner")
|
||||||
}
|
}
|
||||||
|
|
||||||
srv := server.New(c, ds, runner)
|
srv := server.New(ds, runner)
|
||||||
srv.Run(ctx)
|
srv.Run(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user