2015-10-05 14:06:26 +08:00
|
|
|
package bebop
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
2016-07-14 01:01:36 +08:00
|
|
|
"github.com/hybridgroup/gobot"
|
2016-02-22 13:21:24 +08:00
|
|
|
"github.com/hybridgroup/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-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, len(a.Connect()), 0)
|
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-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, a.Connect()[0], errors.New("connection error"))
|
2015-10-05 14:06:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBebopAdaptorFinalize(t *testing.T) {
|
|
|
|
a := initTestBebopAdaptor()
|
|
|
|
a.Connect()
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, len(a.Finalize()), 0)
|
2015-10-05 14:06:26 +08:00
|
|
|
}
|