Skip to content

Commit

Permalink
gpio: increase test coverage for PIR and servo drivers
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Mar 21, 2017
1 parent 224f089 commit d4d2c6e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/gpio/pir_motion_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gpio

import (
"errors"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -85,3 +86,14 @@ func TestPIRMotionDriverStart(t *testing.T) {
t.Errorf("PIRMotionDriver Event \"Error\" was not published")
}
}

func TestPIRDriverDefaultName(t *testing.T) {
d := initTestPIRMotionDriver()
gobottest.Assert(t, strings.HasPrefix(d.Name(), "PIR"), true)
}

func TestPIRDriverSetName(t *testing.T) {
d := initTestPIRMotionDriver()
d.SetName("mybot")
gobottest.Assert(t, d.Name(), "mybot")
}
12 changes: 12 additions & 0 deletions drivers/gpio/servo_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gpio

import (
"errors"
"strings"
"testing"

"gobot.io/x/gobot"
Expand Down Expand Up @@ -75,3 +76,14 @@ func TestServoDriverCenter(t *testing.T) {
d.Center()
gobottest.Assert(t, d.CurrentAngle, uint8(90))
}

func TestServoDriverDefaultName(t *testing.T) {
d := initTestServoDriver()
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Servo"), true)
}

func TestServoDriverSetName(t *testing.T) {
d := initTestServoDriver()
d.SetName("mybot")
gobottest.Assert(t, d.Name(), "mybot")
}

0 comments on commit d4d2c6e

Please sign in to comment.