From 3713a89881b3e9205aaa93f24b1e5e11fd6f00af Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 29 Apr 2017 12:50:39 +0200 Subject: [PATCH] tinkerboard: increase test coverage Signed-off-by: deadprogram --- platforms/tinkerboard/adaptor_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/platforms/tinkerboard/adaptor_test.go b/platforms/tinkerboard/adaptor_test.go index cc8c7993..4d06a730 100644 --- a/platforms/tinkerboard/adaptor_test.go +++ b/platforms/tinkerboard/adaptor_test.go @@ -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) +}