forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot_test.go
58 lines (53 loc) · 1.63 KB
/
robot_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package gobot
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Robot", func() {
var (
someRobot Robot
)
BeforeEach(func() {
someRobot = newTestRobot("")
})
Context("when valid", func() {
It("initName should not change name when already set", func() {
someRobot.Name = "Bumblebee"
someRobot.initName()
Expect(someRobot.Name).To(Equal("Bumblebee"))
})
It("initName should set random name when not set", func() {
someRobot.initName()
Expect(someRobot.Name).NotTo(BeNil())
Expect(someRobot.Name).NotTo(Equal("Bumblebee"))
})
It("initCommands should set RobotCommands equal to Commands Key", func() {
someRobot.initCommands()
Expect(someRobot.RobotCommands).To(Equal([]string{"Command1", "Command2"}))
})
It("GetDevices should return robot devices", func() {
someRobot.initDevices()
Expect(someRobot.GetDevices).NotTo(BeNil())
})
It("GetDevice should return a robot device", func() {
someRobot.initDevices()
Expect(someRobot.GetDevice("Device 1").Name).To(Equal("Device 1"))
})
It("initConnections should initialize connections", func() {
someRobot.initConnections()
Expect(len(someRobot.connections)).To(Equal(3))
})
It("initDevices should initialize devices", func() {
someRobot.initDevices()
Expect(len(someRobot.devices)).To(Equal(3))
})
It("startConnections should connect all connections", func() {
someRobot.initConnections()
Expect(someRobot.startConnections()).To(Equal(true))
})
It("startDevices should start all devices", func() {
someRobot.initDevices()
Expect(someRobot.startDevices()).To(Equal(true))
})
})
})