More test coverage

This commit is contained in:
Adrian Zankich 2013-12-31 13:29:01 -08:00
parent d6d9e89e96
commit 50db5504b8
3 changed files with 37 additions and 5 deletions

View File

@ -52,7 +52,3 @@ func (c *connection) Reconnect() bool {
log.Println("Reconnecting to " + c.Name + " on port " + c.Port + "...")
return c.Adaptor.Reconnect()
}
func (c *connection) AdaptorName() string {
return c.Name
}

33
connection_test.go Normal file
View File

@ -0,0 +1,33 @@
package gobot
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Connection", func() {
var (
someRobot Robot
)
BeforeEach(func() {
someRobot = newTestRobot("")
someRobot.startRobot()
})
Context("when valid", func() {
It("Connect should call adaptor Connect", func() {
Expect(someRobot.Connections[0].Connect()).To(Equal(true))
})
It("Finalize should call adaptor Finalize", func() {
Expect(someRobot.Connections[0].Connect()).To(Equal(true))
})
It("Disconnect should call adaptor Disconnect", func() {
Expect(someRobot.Connections[0].Connect()).To(Equal(true))
})
It("Reconnect should call adaptor Reconnect", func() {
Expect(someRobot.Connections[0].Connect()).To(Equal(true))
})
})
})

View File

@ -13,12 +13,15 @@ var _ = Describe("Device", func() {
BeforeEach(func() {
someRobot = newTestRobot("")
someRobot.startRobot()
})
Context("when valid", func() {
It("Commands should return device commands", func() {
someRobot.initDevices()
Expect(someRobot.devices[0].Commands()).To(Equal([]string{"DriverCommand1", "DriverCommand2", "DriverCommand3"}))
})
It("Start should call driver start", func() {
Expect(someRobot.Devices[0].Start()).To(Equal(true))
})
})
})