forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot_test.go
47 lines (42 loc) · 1.13 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
package gobot
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"os"
)
var _ = Describe("Robot", func() {
var (
r *Robot
)
Context("when valid", func() {
BeforeEach(func() {
r = newTestRobot("")
r.master = NewMaster()
r.master.trap = func(c chan os.Signal) {
c <- os.Interrupt
}
r.Start()
})
It("should set random name when not set", func() {
Expect(r.Name).NotTo(BeNil())
})
It("GetDevice should return nil if device doesn't exist", func() {
Expect(r.GetDevice("Device 4")).To(BeNil())
})
It("GetDevice should return device", func() {
Expect(r.GetDevice("Device 1").Name).To(Equal("Device 1"))
})
It("GetDevices should return devices", func() {
Expect(len(r.GetDevices())).To(Equal(3))
})
It("GetConnection should return nil if connection doesn't exist", func() {
Expect(r.GetConnection("Connection 4")).To(BeNil())
})
It("GetConnection should return connection", func() {
Expect(r.GetConnection("Connection 1").Name).To(Equal("Connection 1"))
})
It("GetConnections should return connections", func() {
Expect(len(r.GetConnections())).To(Equal(3))
})
})
})