2015-10-05 14:06:26 +08:00
|
|
|
package bebop
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
2016-02-22 13:21:24 +08:00
|
|
|
"github.com/hybridgroup/gobot/gobottest"
|
2015-10-05 14:06:26 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func initTestBebopAdaptor() *BebopAdaptor {
|
|
|
|
a := NewBebopAdaptor("bot")
|
|
|
|
a.connect = func(b *BebopAdaptor) (err error) {
|
|
|
|
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-02-22 13:21:24 +08:00
|
|
|
a.connect = func(a *BebopAdaptor) 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
|
|
|
}
|