1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/platforms/joystick/joystick_adaptor_test.go
deadprogram af21d98074 core: update Joystick platform to simply return error
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-11-07 21:29:51 +01:00

35 lines
638 B
Go

package joystick
import (
"errors"
"testing"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/gobottest"
)
var _ gobot.Adaptor = (*Adaptor)(nil)
func initTestAdaptor() *Adaptor {
a := NewAdaptor()
a.connect = func(j *Adaptor) (err error) {
j.joystick = &testJoystick{}
return nil
}
return a
}
func TestAdaptorConnect(t *testing.T) {
a := initTestAdaptor()
gobottest.Assert(t, a.Connect(), nil)
a = NewAdaptor()
gobottest.Assert(t, a.Connect(), errors.New("No joystick available"))
}
func TestAdaptorFinalize(t *testing.T) {
a := initTestAdaptor()
a.Connect()
gobottest.Assert(t, a.Finalize(), nil)
}