@@ -5,11 +5,13 @@ import (
55 "context"
66 "testing"
77 "time"
8+
9+ "github.com/hipsterbrown/feetech-servo/transports"
810)
911
1012func TestBus_Ping (t * testing.T ) {
1113 // Set up mock with ping response + model number read response
12- mock := & MockTransport {}
14+ mock := & transports. MockTransport {}
1315 readIdx := 0
1416 responses := [][]byte {
1517 {0xFF , 0xFF , 0x01 , 0x02 , 0x00 , 0xFC }, // Ping response
@@ -55,7 +57,7 @@ func TestBus_Ping(t *testing.T) {
5557
5658func TestBus_ReadRegister (t * testing.T ) {
5759 // Mock response for reading 2 bytes
58- mock := & MockTransport {
60+ mock := & transports. MockTransport {
5961 ReadData : []byte {0xFF , 0xFF , 0x01 , 0x04 , 0x00 , 0x00 , 0x08 , 0xF2 }, // Position 2048
6062 }
6163
@@ -82,7 +84,7 @@ func TestBus_ReadRegister(t *testing.T) {
8284}
8385
8486func TestBus_WriteRegister (t * testing.T ) {
85- mock := & MockTransport {
87+ mock := & transports. MockTransport {
8688 ReadData : []byte {0xFF , 0xFF , 0x01 , 0x02 , 0x00 , 0xFC }, // Ack response
8789 }
8890
@@ -109,7 +111,7 @@ func TestBus_WriteRegister(t *testing.T) {
109111}
110112
111113func TestBus_SyncWrite (t * testing.T ) {
112- mock := & MockTransport {}
114+ mock := & transports. MockTransport {}
113115
114116 bus , _ := NewBus (BusConfig {
115117 Transport : mock ,
@@ -139,7 +141,7 @@ func TestBus_SyncWrite(t *testing.T) {
139141
140142func TestBus_SyncRead (t * testing.T ) {
141143 // Mock two servo responses
142- mock := & MockTransport {
144+ mock := & transports. MockTransport {
143145 ReadData : []byte {
144146 0xFF , 0xFF , 0x01 , 0x04 , 0x00 , 0x00 , 0x08 , 0xF2 , // ID 1, position 2048
145147 0xFF , 0xFF , 0x02 , 0x04 , 0x00 , 0x00 , 0x04 , 0xF5 , // ID 2, position 1024
@@ -176,7 +178,7 @@ func TestBus_SyncRead(t *testing.T) {
176178}
177179
178180func TestBus_SyncRead_SCSUnsupported (t * testing.T ) {
179- mock := & MockTransport {}
181+ mock := & transports. MockTransport {}
180182
181183 bus , _ := NewBus (BusConfig {
182184 Transport : mock ,
@@ -192,7 +194,7 @@ func TestBus_SyncRead_SCSUnsupported(t *testing.T) {
192194}
193195
194196func TestBus_InvalidID (t * testing.T ) {
195- mock := & MockTransport {}
197+ mock := & transports. MockTransport {}
196198 bus , _ := NewBus (BusConfig {Transport : mock })
197199 defer bus .Close ()
198200
@@ -211,7 +213,7 @@ func TestBus_InvalidID(t *testing.T) {
211213}
212214
213215func TestBus_Close (t * testing.T ) {
214- mock := & MockTransport {}
216+ mock := & transports. MockTransport {}
215217 bus , _ := NewBus (BusConfig {Transport : mock })
216218
217219 err := bus .Close ()
@@ -230,7 +232,7 @@ func TestBus_Close(t *testing.T) {
230232}
231233
232234func TestBus_ClosedOperations (t * testing.T ) {
233- mock := & MockTransport {}
235+ mock := & transports. MockTransport {}
234236 bus , _ := NewBus (BusConfig {Transport : mock })
235237 bus .Close ()
236238
@@ -243,7 +245,7 @@ func TestBus_ClosedOperations(t *testing.T) {
243245}
244246
245247func TestServo_Position (t * testing.T ) {
246- mock := & MockTransport {
248+ mock := & transports. MockTransport {
247249 ReadData : []byte {0xFF , 0xFF , 0x01 , 0x04 , 0x00 , 0x00 , 0x08 , 0xF2 },
248250 }
249251
@@ -267,7 +269,7 @@ func TestServo_Position(t *testing.T) {
267269}
268270
269271func TestServo_SetPosition (t * testing.T ) {
270- mock := & MockTransport {
272+ mock := & transports. MockTransport {
271273 ReadData : []byte {0xFF , 0xFF , 0x01 , 0x02 , 0x00 , 0xFC },
272274 }
273275
@@ -294,7 +296,7 @@ func TestServo_SetPosition(t *testing.T) {
294296}
295297
296298func TestServo_TorqueEnable (t * testing.T ) {
297- mock := & MockTransport {
299+ mock := & transports. MockTransport {
298300 ReadData : []byte {0xFF , 0xFF , 0x01 , 0x02 , 0x00 , 0xFC },
299301 }
300302
@@ -323,7 +325,7 @@ func TestServo_TorqueEnable(t *testing.T) {
323325
324326func TestBus_ContextCancellation (t * testing.T ) {
325327 // Simulate slow transport
326- mock := & MockTransport {
328+ mock := & transports. MockTransport {
327329 ReadFunc : func (p []byte ) (int , error ) {
328330 time .Sleep (500 * time .Millisecond )
329331 return 0 , nil
0 commit comments