Skip to content

Commit

Permalink
Increase edison test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Dec 19, 2014
1 parent 3b82731 commit 5cdba38
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions platforms/intel-iot/edison/edison_adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ func (NullReadWriteCloser) Read(b []byte) (int, error) {
return len(b), nil
}

var closeErr error = nil

func (NullReadWriteCloser) Close() error {
return nil
return closeErr
}

func initTestEdisonAdaptor() (*EdisonAdaptor, *sysfs.MockFilesystem) {
Expand Down Expand Up @@ -98,17 +100,29 @@ func initTestEdisonAdaptor() (*EdisonAdaptor, *sysfs.MockFilesystem) {
return a, fs
}

func TestEdisonAdaptor(t *testing.T) {
a, _ := initTestEdisonAdaptor()
gobot.Assert(t, a.Name(), "myAdaptor")
}
func TestEdisonAdaptorConnect(t *testing.T) {
a, _ := initTestEdisonAdaptor()
gobot.Assert(t, len(a.Connect()), 0)

a = NewEdisonAdaptor("myAdaptor")
sysfs.SetFilesystem(sysfs.NewMockFilesystem([]string{}))
gobot.Refute(t, len(a.Connect()), 0)
}

func TestEdisonAdaptorFinalize(t *testing.T) {
a, _ := initTestEdisonAdaptor()
a.DigitalWrite("3", 1)
a.PwmWrite("5", 100)
a.i2cDevice = new(NullReadWriteCloser)
a.i2cDevice = &NullReadWriteCloser{}
gobot.Assert(t, len(a.Finalize()), 0)

closeErr = errors.New("close error")
sysfs.SetFilesystem(sysfs.NewMockFilesystem([]string{}))
gobot.Refute(t, len(a.Finalize()), 0)
}

func TestEdisonAdaptorDigitalIO(t *testing.T) {
Expand Down

0 comments on commit 5cdba38

Please sign in to comment.