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
Showing
5 changed files
with
124 additions
and
23 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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package gobot | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Master", func() { | ||
|
||
var ( | ||
myMaster Master | ||
) | ||
|
||
BeforeEach(func() { | ||
myMaster = Master{ | ||
Robots: []Robot{ | ||
Robot{ | ||
Name: "Robot 1", | ||
Connections: []Connection{newTestAdaptor("Connection 1")}, | ||
Devices: []Device{newTestDriver("Device 1")}, | ||
}, | ||
Robot{ | ||
Name: "Robot 2", | ||
Connections: []Connection{newTestAdaptor("Connection 2")}, | ||
Devices: []Device{newTestDriver("Device 2")}, | ||
}, | ||
Robot{ | ||
Name: "Robot 3", | ||
Connections: []Connection{newTestAdaptor("Connection 3")}, | ||
Devices: []Device{newTestDriver("Device 3")}, | ||
}, | ||
}, | ||
} | ||
myMaster.Robots[0].initDevices() | ||
myMaster.Robots[0].initConnections() | ||
}) | ||
|
||
Context("when valid", func() { | ||
It("should Find the specific robot", func() { | ||
Expect(myMaster.FindRobot("Robot 1").Name).To(Equal("Robot 1")) | ||
}) | ||
It("should Find the specific robot device", func() { | ||
Expect(myMaster.FindRobotDevice("Robot 1", "Device 1").Name).To(Equal("Device 1")) | ||
}) | ||
It("should Find the specific robot connection", func() { | ||
Expect(myMaster.FindRobotConnection("Robot 1", "Connection 1").Name).To(Equal("Connection 1")) | ||
}) | ||
}) | ||
}) |
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gobot | ||
|
||
type testDriver struct { | ||
Driver | ||
} | ||
|
||
//func (me *testDriver) Start() bool { return true } | ||
func (me *testDriver) Start() bool { return true } | ||
|
||
type testAdaptor struct { | ||
Adaptor | ||
} | ||
|
||
func (me *testAdaptor) Finalize() bool { return true } | ||
func (me *testAdaptor) Connect() bool { return true } | ||
func (me *testAdaptor) Disconnect() bool { return true } | ||
func (me *testAdaptor) Reconnect() bool { return true } | ||
|
||
func newTestDriver(name string) *testDriver { | ||
d := new(testDriver) | ||
d.Name = name | ||
return d | ||
} | ||
func newTestAdaptor(name string) *testAdaptor { | ||
a := new(testAdaptor) | ||
a.Name = name | ||
return a | ||
} |