2015-10-05 14:06:26 +08:00
|
|
|
package bebop
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/gobottest"
|
2015-10-05 14:06:26 +08:00
|
|
|
)
|
|
|
|
|
2016-09-25 22:05:24 +08:00
|
|
|
var _ gobot.Adaptor = (*Adaptor)(nil)
|
2016-07-14 01:01:36 +08:00
|
|
|
|
2016-09-25 22:05:24 +08:00
|
|
|
func initTestBebopAdaptor() *Adaptor {
|
|
|
|
a := NewAdaptor()
|
|
|
|
a.connect = func(b *Adaptor) (err error) {
|
2015-10-05 14:06:26 +08:00
|
|
|
b.drone = &testDrone{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBebopAdaptorConnect(t *testing.T) {
|
|
|
|
a := initTestBebopAdaptor()
|
2016-11-08 00:35:03 +08:00
|
|
|
gobottest.Assert(t, a.Connect(), nil)
|
2015-10-05 14:06:26 +08:00
|
|
|
|
2016-09-25 22:05:24 +08:00
|
|
|
a.connect = func(a *Adaptor) error {
|
2015-10-05 14:06:26 +08:00
|
|
|
return errors.New("connection error")
|
|
|
|
}
|
2016-11-08 00:35:03 +08:00
|
|
|
gobottest.Assert(t, a.Connect(), errors.New("connection error"))
|
2015-10-05 14:06:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBebopAdaptorFinalize(t *testing.T) {
|
|
|
|
a := initTestBebopAdaptor()
|
|
|
|
a.Connect()
|
2016-11-08 00:35:03 +08:00
|
|
|
gobottest.Assert(t, a.Finalize(), nil)
|
2015-10-05 14:06:26 +08:00
|
|
|
}
|