diff --git a/mqttdevice/mqttdevice.go b/mqttdevice/mqttdevice.go index 1fc1d1f..df9801b 100644 --- a/mqttdevice/mqttdevice.go +++ b/mqttdevice/mqttdevice.go @@ -2,7 +2,7 @@ package mqttdevice import ( "fmt" - "github.com/cyrilix/robocar-base/mode" + "github.com/cyrilix/robocar-base/types" MQTT "github.com/eclipse/paho.mqtt.golang" "io" "log" @@ -128,12 +128,12 @@ func (m *MqttValue) Float64Value() (float64, error) { func (m *MqttValue) StringValue() (string, error) { return string(*m), nil } -func (m *MqttValue) DriveModeValue() (mode.DriveMode, error) { +func (m *MqttValue) DriveModeValue() (types.DriveMode, error) { val, err := m.IntValue() if err != nil { - return mode.DriveModeInvalid, err + return types.DriveModeInvalid, err } - return mode.DriveMode(val), nil + return types.DriveMode(val), nil } func (m *MqttValue) ByteSliceValue() ([]byte, error) { return *m, nil diff --git a/mqttdevice/mqttdevice_test.go b/mqttdevice/mqttdevice_test.go index a6a359e..b6cc020 100644 --- a/mqttdevice/mqttdevice_test.go +++ b/mqttdevice/mqttdevice_test.go @@ -1,7 +1,7 @@ package mqttdevice import ( - "github.com/cyrilix/robocar-base/mode" + "github.com/cyrilix/robocar-base/types" "github.com/cyrilix/robocar-base/testtools/docker" mqtt "github.com/eclipse/paho.mqtt.golang" "testing" @@ -192,11 +192,11 @@ func TestMqttValue_StringValue(t *testing.T) { func TestMqttValue_DriveModeValue(t *testing.T) { cases := []struct { value MqttValue - expected mode.DriveMode + expected types.DriveMode }{ - {NewMqttValue(mode.DriveModeUser), mode.DriveModeUser}, - {NewMqttValue(mode.DriveModePilot), mode.DriveModePilot}, - {NewMqttValue(mode.DriveModeInvalid), mode.DriveModeInvalid}, + {NewMqttValue(types.DriveModeUser), types.DriveModeUser}, + {NewMqttValue(types.DriveModePilot), types.DriveModePilot}, + {NewMqttValue(types.DriveModeInvalid), types.DriveModeInvalid}, } for _, c := range cases { val, err := c.value.DriveModeValue() diff --git a/mode/mode.go b/types/mode.go similarity index 97% rename from mode/mode.go rename to types/mode.go index 06c3ac3..de839a9 100644 --- a/mode/mode.go +++ b/types/mode.go @@ -1,4 +1,4 @@ -package mode +package types import ( "log" @@ -32,6 +32,5 @@ func ParseString(val string) DriveMode { default: log.Printf("invalid DriveMode: %v", val) return DriveModeInvalid - } } diff --git a/mode/mode_test.go b/types/mode_test.go similarity index 98% rename from mode/mode_test.go rename to types/mode_test.go index efaeaca..f49af40 100644 --- a/mode/mode_test.go +++ b/types/mode_test.go @@ -1,4 +1,4 @@ -package mode +package types import "testing"