test: add test coverage for JSONDevices

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-02-25 12:31:41 +01:00
parent 2bba294b2f
commit c54763046b
1 changed files with 10 additions and 0 deletions

View File

@ -25,3 +25,13 @@ func TestRobotToJSON(t *testing.T) {
gobottest.Assert(t, len(json.Devices), r.Devices().Len()) gobottest.Assert(t, len(json.Devices), r.Devices().Len())
gobottest.Assert(t, len(json.Commands), len(r.Commands())) gobottest.Assert(t, len(json.Commands), len(r.Commands()))
} }
func TestRobotDevicesToJSON(t *testing.T) {
r := newTestRobot("Robot99")
json := NewJSONRobot(r)
gobottest.Assert(t, len(json.Devices), r.Devices().Len())
gobottest.Assert(t, json.Devices[0].Name, "Device1")
gobottest.Assert(t, json.Devices[0].Driver, "*gobot.testDriver")
gobottest.Assert(t, json.Devices[0].Connection, "Connection1")
gobottest.Assert(t, len(json.Devices[0].Commands), 1)
}