1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/sysfs/i2c_device_test.go
2014-11-07 16:56:13 -08:00

32 lines
524 B
Go

package sysfs
import (
"github.com/hybridgroup/gobot"
"io"
"os"
"testing"
)
func TestNewI2cDevice(t *testing.T) {
fs := NewMockFilesystem([]string{})
SetFilesystem(fs)
i, err := NewI2cDevice(os.DevNull, 0xff)
gobot.Refute(t, err, nil)
fs = NewMockFilesystem([]string{
"/dev/i2c-1",
})
SetFilesystem(fs)
i, err = NewI2cDevice("/dev/i2c-1", 0xff)
gobot.Refute(t, err, nil)
SetSyscall(&MockSyscall{})
i, err = NewI2cDevice("/dev/i2c-1", 0xff)
gobot.Assert(t, err, nil)
var _ io.ReadWriteCloser = i
}