Ver Fonte

export manual transport abstraction names

高宇轩 há 3 meses atrás
pai
commit
4cd3cb2273
2 ficheiros alterados com 11 adições e 1 exclusões
  1. 5 1
      pkg/hth6400/hth6400.go
  2. 6 0
      pkg/hth6400/hth6400_test.go

+ 5 - 1
pkg/hth6400/hth6400.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"fmt"
 	"prod2u6400-uartkit/internal/i2creg"
 	"prod2u6400-uartkit/internal/i2creg"
 	"prod2u6400-uartkit/internal/protocol"
 	"prod2u6400-uartkit/internal/protocol"
+	"prod2u6400-uartkit/internal/transport"
 )
 )
 
 
 type SetAll = protocol.SetAll
 type SetAll = protocol.SetAll
@@ -12,10 +13,13 @@ type Frame = protocol.Frame
 type Ack = protocol.Ack
 type Ack = protocol.Ack
 type I2CTransaction = i2creg.Transaction
 type I2CTransaction = i2creg.Transaction
 
 
-type UARTTransport interface {
+type UARTTransport = transport.UARTTransport
+type I2CRegisterTransport interface {
 	WriteSetAll(context.Context, SetAll) error
 	WriteSetAll(context.Context, SetAll) error
 	GetSnapshot(context.Context) ([]byte, error)
 	GetSnapshot(context.Context) ([]byte, error)
 }
 }
+type MockTransport = transport.MockTransport
+type ReplayTransport = transport.ReplayTransport
 
 
 func SetAllFrame(s SetAll) ([]byte, error) { return protocol.EncodeSetAll(s) }
 func SetAllFrame(s SetAll) ([]byte, error) { return protocol.EncodeSetAll(s) }
 func GetSnapshotFrame() []byte             { return protocol.EncodeGetSnapshot() }
 func GetSnapshotFrame() []byte             { return protocol.EncodeGetSnapshot() }

+ 6 - 0
pkg/hth6400/hth6400_test.go

@@ -25,3 +25,9 @@ func TestPublicSetAllAndDecode(t *testing.T) {
 		t.Fatal("SET_ALL must not decode as ACK")
 		t.Fatal("SET_ALL must not decode as ACK")
 	}
 	}
 }
 }
+
+func TestPublicTransportNames(t *testing.T) {
+	var _ UARTTransport = (*MockTransport)(nil)
+	var _ I2CRegisterTransport = (*MockTransport)(nil)
+	var _ I2CRegisterTransport = (*ReplayTransport)(nil)
+}