mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-05-02 22:17:12 +08:00
raspi: increase test coverage
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
722e1b8e1c
commit
f261a166f9
@ -31,7 +31,7 @@ type Adaptor struct {
|
||||
// NewAdaptor creates a Raspi Adaptor
|
||||
func NewAdaptor() *Adaptor {
|
||||
r := &Adaptor{
|
||||
name: "RaspberryPi",
|
||||
name: gobot.DefaultName("RaspberryPi"),
|
||||
digitalPins: make(map[int]sysfs.DigitalPin),
|
||||
pwmPins: []int{},
|
||||
}
|
||||
|
@ -30,6 +30,13 @@ Serial : 000000003bc748ea
|
||||
return a
|
||||
}
|
||||
|
||||
func TestRaspiAdaptorName(t *testing.T) {
|
||||
a := initTestAdaptor()
|
||||
gobottest.Assert(t, strings.HasPrefix(a.Name(), "RaspberryPi"), true)
|
||||
a.SetName("NewName")
|
||||
gobottest.Assert(t, a.Name(), "NewName")
|
||||
}
|
||||
|
||||
func TestAdaptor(t *testing.T) {
|
||||
readFile = func() ([]byte, error) {
|
||||
return []byte(`
|
||||
@ -39,7 +46,7 @@ Serial : 000000003bc748ea
|
||||
`), nil
|
||||
}
|
||||
a := NewAdaptor()
|
||||
gobottest.Assert(t, a.Name(), "RaspberryPi")
|
||||
gobottest.Assert(t, strings.HasPrefix(a.Name(), "RaspberryPi"), true)
|
||||
gobottest.Assert(t, a.i2cDefaultBus, 1)
|
||||
gobottest.Assert(t, a.revision, "3")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user