forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
921b593
commit e7c857b
Showing
1 changed file
with
10 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,37 @@ | ||
package gobot | ||
|
||
import ( | ||
"os" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"os" | ||
) | ||
|
||
var _ = Describe("Master", func() { | ||
var ( | ||
myMaster *Master | ||
m *Master | ||
) | ||
|
||
BeforeEach(func() { | ||
myMaster = NewMaster() | ||
myMaster.trap = func(c chan os.Signal) { | ||
m = NewMaster() | ||
m.trap = func(c chan os.Signal) { | ||
c <- os.Interrupt | ||
} | ||
myMaster.Robots = []*Robot{ | ||
m.Robots = []*Robot{ | ||
newTestRobot("Robot 1"), | ||
newTestRobot("Robot 2"), | ||
newTestRobot("Robot 3"), | ||
} | ||
startApi = func(m *api) {} | ||
myMaster.Start() | ||
m.Api = NewApi() | ||
m.Api.startFunc = func(m *api) {} | ||
m.Start() | ||
}) | ||
|
||
Context("when valid", func() { | ||
It("should Find the specific robot", func() { | ||
Expect(myMaster.FindRobot("Robot 1").Name).To(Equal("Robot 1")) | ||
Expect(m.FindRobot("Robot 1").Name).To(Equal("Robot 1")) | ||
}) | ||
It("should return nil if Robot doesn't exist", func() { | ||
Expect(myMaster.FindRobot("Robot 4")).To(BeNil()) | ||
}) | ||
It("should Find the specific robot device", func() { | ||
Expect(myMaster.FindRobotDevice("Robot 2", "Device 2").Name).To(Equal("Device 2")) | ||
}) | ||
It("should return nil if the robot device doesn't exist", func() { | ||
Expect(myMaster.FindRobotDevice("Robot 4", "Device 2")).To(BeNil()) | ||
}) | ||
It("should Find the specific robot connection", func() { | ||
Expect(myMaster.FindRobotConnection("Robot 3", "Connection 1").Name).To(Equal("Connection 1")) | ||
}) | ||
It("should return nil if the robot connection doesn't exist", func() { | ||
Expect(myMaster.FindRobotConnection("Robot 4", "Connection 1")).To(BeNil()) | ||
}) | ||
It("Commands should return device commands", func() { | ||
Expect(myMaster.FindRobotDevice("Robot 2", "Device 1").Commands()).To(Equal([]string{"TestDriverCommand", "DriverCommand"})) | ||
Expect(m.FindRobot("Robot 4")).To(BeNil()) | ||
}) | ||
}) | ||
}) |