Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Dec 31, 2013
1 parent 7da1b80 commit d6d9e89
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
5 changes: 1 addition & 4 deletions device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ var _ = Describe("Device", func() {
)

BeforeEach(func() {
someRobot = Robot{
Connections: []Connection{newTestAdaptor("Connection 1")},
Devices: []Device{newTestDriver("Device 1")},
}
someRobot = newTestRobot("")
})

Context("when valid", func() {
Expand Down
30 changes: 9 additions & 21 deletions master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,19 @@ import (
var _ = Describe("Master", func() {

var (
myMaster Master
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 = GobotMaster()
myMaster.Robots = []Robot{
newTestRobot("Robot 1"),
newTestRobot("Robot 2"),
newTestRobot("Robot 3"),
}
for s := range myMaster.Robots {
myMaster.Robots[s].startRobot()
}
myMaster.Robots[0].initDevices()
myMaster.Robots[0].initConnections()
})

Context("when valid", func() {
Expand Down
9 changes: 1 addition & 8 deletions robot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ var _ = Describe("Robot", func() {
)

BeforeEach(func() {
someRobot = Robot{
Connections: []Connection{newTestAdaptor("Connection 1"), newTestAdaptor("Connection 2"), newTestAdaptor("Connection 3")},
Devices: []Device{newTestDriver("Device 1"), newTestDriver("Device 2"), newTestDriver("Device 3")},
Commands: map[string]interface{}{
"Command1": func() {},
"Command2": func() {},
},
}
someRobot = newTestRobot("")
})

Context("when valid", func() {
Expand Down
12 changes: 12 additions & 0 deletions test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ func newTestAdaptor(name string) *testAdaptor {
a.Name = name
return a
}

func newTestRobot(name string) Robot {
return Robot{
Name: name,
Connections: []Connection{newTestAdaptor("Connection 1"), newTestAdaptor("Connection 2"), newTestAdaptor("Connection 3")},
Devices: []Device{newTestDriver("Device 1"), newTestDriver("Device 2"), newTestDriver("Device 3")},
Commands: map[string]interface{}{
"Command1": func() {},
"Command2": func() {},
},
}
}

0 comments on commit d6d9e89

Please sign in to comment.