Skip to content

Commit

Permalink
Gobot tests are green again
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed May 3, 2014
1 parent e500296 commit 819ec4f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 72 deletions.
37 changes: 27 additions & 10 deletions gobot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,49 @@ import (
"os"
)

var _ = Describe("Master", func() {
var _ = Describe("Gobot", func() {
var (
m *Master
g *Gobot
)

BeforeEach(func() {
m = NewMaster()
m.trap = func(c chan os.Signal) {
g = NewGobot()
g.trap = func(c chan os.Signal) {
c <- os.Interrupt
}
m.Robots = []*Robot{
g.Robots = []*Robot{
newTestRobot("Robot 1"),
newTestRobot("Robot 2"),
newTestRobot("Robot 3"),
}
m.Api = NewApi()
m.Api.startFunc = func(m *api) {}
m.Start()
g.Start()
})

Context("when valid", func() {
It("should Find the specific robot", func() {
Expect(m.FindRobot("Robot 1").Name).To(Equal("Robot 1"))
Expect(g.Robot("Robot 1").Name).To(Equal("Robot 1"))
})
It("should return nil if Robot doesn't exist", func() {
Expect(m.FindRobot("Robot 4")).To(BeNil())
Expect(g.Robot("Robot 4")).To(BeNil())
})
It("Device should return nil if device doesn't exist", func() {
Expect(g.Robot("Robot 1").Device("Device 4")).To(BeNil())
})
It("Device should return device", func() {
Expect(g.Robot("Robot 1").Device("Device 1").Name).To(Equal("Device 1"))
})
It("Devices should return devices", func() {
Expect(len(g.Robot("Robot 1").Devices())).To(Equal(3))
})
It("Connection should return nil if connection doesn't exist", func() {
Expect(g.Robot("Robot 1").Connection("Connection 4")).To(BeNil())
})
It("Connection should return connection", func() {
Expect(g.Robot("Robot 1").Connection("Connection 1").Name).To(Equal("Connection 1"))
})
It("Connections should return connections", func() {
Expect(len(g.Robot("Robot 1").Connections())).To(Equal(3))
})

})
})
47 changes: 0 additions & 47 deletions robot_test.go

This file was deleted.

20 changes: 5 additions & 15 deletions test_helper.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package gobot

/*
import (
"fmt"
. "github.com/hybridgroup/gobot/adaptor"
. "github.com/hybridgroup/gobot/driver"
)

type testStruct struct {
Expand Down Expand Up @@ -77,15 +73,11 @@ func newTestRobot(name string) *Robot {
driver1 := newTestDriver("Device 1", adaptor1)
driver2 := newTestDriver("Device 2", adaptor2)
driver3 := newTestDriver("Device 3", adaptor3)
return &Robot{
Name: name,
//Connections: []Connection{adaptor1, adaptor2, adaptor3},
//Devices: []Device{driver1, driver2, driver3},
Work: func() {},
Commands: map[string]interface{}{
"robotTestFunction": robotTestFunction,
},
}
work := func() {}
//Commands := map[string]interface{}{
// "robotTestFunction": robotTestFunction,
//}
return NewRobot(name, []Connection{adaptor1, adaptor2, adaptor3}, []Device{driver1, driver2, driver3}, work)
}

func newTestStruct() *testStruct {
Expand All @@ -94,5 +86,3 @@ func newTestStruct() *testStruct {
s.f = 0.2
return s
}
*/

0 comments on commit 819ec4f

Please sign in to comment.