diff --git a/api.go b/api.go index 2314c479..3eadd74e 100644 --- a/api.go +++ b/api.go @@ -33,10 +33,14 @@ type jsonConnection struct { Adaptor string `json:"adaptor"` } -func (me *api) StartApi() { +var startApi = func(me *api) { go me.server.Run() } +func (me *api) StartApi() { + startApi(me) +} + func Api(bot *Master) *api { a := new(api) a.master = bot diff --git a/api_test.go b/api_test.go index ff456998..246d1881 100644 --- a/api_test.go +++ b/api_test.go @@ -3,7 +3,6 @@ package gobot import ( "bytes" "encoding/json" - //"github.com/go-martini/martini" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "io/ioutil" @@ -19,8 +18,8 @@ var _ = Describe("Master", func() { ) BeforeEach(func() { - myMaster = GobotMaster() - //startApi = func(m *martini.ClassicMartini) {} + myMaster = GobotMaster() + startApi = func(m *api) {} a = Api(myMaster) myMaster.Robots = []*Robot{ newTestRobot("Robot 1"), diff --git a/master_test.go b/master_test.go index c4027738..26c1c212 100644 --- a/master_test.go +++ b/master_test.go @@ -18,6 +18,7 @@ var _ = Describe("Master", func() { newTestRobot("Robot 2"), newTestRobot("Robot 3"), } + startApi = func(m *api) {} trap = func(c chan os.Signal) { c <- os.Interrupt }