From c54763046b9704bea25665e254c4d2b6e7c86b5a Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 25 Feb 2017 12:31:41 +0100 Subject: [PATCH] test: add test coverage for JSONDevices Signed-off-by: deadprogram --- robot_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/robot_test.go b/robot_test.go index 88edb78b..0e0b8808 100644 --- a/robot_test.go +++ b/robot_test.go @@ -25,3 +25,13 @@ func TestRobotToJSON(t *testing.T) { gobottest.Assert(t, len(json.Devices), r.Devices().Len()) 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) +}