gobot.io/x/gobot/v2@v2.1.0/system/spi_access_test.go (about) 1 package system 2 3 import ( 4 "testing" 5 6 "gobot.io/x/gobot/v2/gobottest" 7 ) 8 9 func TestGpioSpi_isSupported(t *testing.T) { 10 // arrange 11 gsa := gpioSpiAccess{} 12 // act 13 got := gsa.isSupported() 14 // assert 15 gobottest.Assert(t, got, true) 16 } 17 18 func TestPeriphioSpi_isSupported(t *testing.T) { 19 var tests = map[string]struct { 20 mockPaths []string 21 want bool 22 }{ 23 "supported": { 24 mockPaths: []string{"/dev/spidev0.0", "/dev/spidev1.0"}, 25 want: true, 26 }, 27 "not_supported": { 28 mockPaths: []string{"/sys/class/gpio/"}, 29 want: false, 30 }, 31 } 32 for name, tc := range tests { 33 t.Run(name, func(t *testing.T) { 34 // arrange 35 fs := newMockFilesystem(tc.mockPaths) 36 psa := periphioSpiAccess{fs: fs} 37 // act 38 got := psa.isSupported() 39 // assert 40 gobottest.Assert(t, got, tc.want) 41 }) 42 } 43 }