tinkerboard: increase test coverage

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-04-29 12:50:39 +02:00
parent b7299c565d
commit 3713a89881
1 changed files with 25 additions and 0 deletions

View File

@ -60,6 +60,7 @@ func TestTinkerboardAdaptorDigitalIO(t *testing.T) {
gobottest.Assert(t, i, 1)
gobottest.Assert(t, a.DigitalWrite("99", 1), errors.New("Not a valid pin"))
gobottest.Assert(t, a.Finalize(), nil)
}
func TestAdaptorDigitalWriteError(t *testing.T) {
@ -163,3 +164,27 @@ func TestTinkerboardGetConnectionInvalidBus(t *testing.T) {
_, err := a.GetConnection(0x01, 99)
gobottest.Assert(t, err, errors.New("Bus number 99 out of range"))
}
func TestTinkerboardFinalizeErrorAfterGPIO(t *testing.T) {
a, fs := initTestTinkerboardAdaptor()
gobottest.Assert(t, a.Connect(), nil)
gobottest.Assert(t, a.DigitalWrite("7", 1), nil)
fs.WithWriteError = true
err := a.Finalize()
gobottest.Assert(t, strings.Contains(err.Error(), "write error"), true)
}
func TestTinkerboardFinalizeErrorAfterPWM(t *testing.T) {
a, fs := initTestTinkerboardAdaptor()
gobottest.Assert(t, a.Connect(), nil)
gobottest.Assert(t, a.PwmWrite("33", 1), nil)
fs.WithWriteError = true
err := a.Finalize()
gobottest.Assert(t, strings.Contains(err.Error(), "write error"), true)
}