From 0a018124455527367cbb5a9e9ed08dff24f39461 Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 14 Aug 2023 23:37:15 -0500 Subject: [PATCH 1/7] set powertrain from device definition --- cmd/devices-api/main.go | 2 +- cmd/devices-api/populate_powertrain.go | 69 ++++++++++++++++--- .../controllers/user_devices_controller.go | 50 +++++++++++--- .../services/device_definitions_service.go | 17 +++++ 4 files changed, 118 insertions(+), 20 deletions(-) diff --git a/cmd/devices-api/main.go b/cmd/devices-api/main.go index 9952b6124..b156241a6 100644 --- a/cmd/devices-api/main.go +++ b/cmd/devices-api/main.go @@ -99,7 +99,7 @@ func main() { subcommands.Register(&populateESDDDataCmd{logger: logger, settings: settings, pdb: pdb, esInstance: deps.getElasticSearchService(), ddSvc: deps.getDeviceDefinitionService()}, "populate data") subcommands.Register(&populateESRegionDataCmd{logger: logger, settings: settings, pdb: pdb, esInstance: deps.getElasticSearchService(), ddSvc: deps.getDeviceDefinitionService()}, "populate data") - subcommands.Register(&populateUSAPowertrainCmd{logger: logger, settings: settings, pdb: pdb, nhtsaService: deps.getNHTSAService()}, "populate data") + subcommands.Register(&populateUSAPowertrainCmd{logger: logger, settings: settings, pdb: pdb, nhtsaService: deps.getNHTSAService(), deviceDefSvc: deps.getDeviceDefinitionService()}, "populate data") subcommands.Register(&stopTaskByKeyCmd{logger: logger, settings: settings, container: deps}, "tasks") diff --git a/cmd/devices-api/populate_powertrain.go b/cmd/devices-api/populate_powertrain.go index d77d8107b..e2b0ac470 100644 --- a/cmd/devices-api/populate_powertrain.go +++ b/cmd/devices-api/populate_powertrain.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "github.com/google/subcommands" "github.com/DIMO-Network/devices-api/internal/config" @@ -20,31 +19,39 @@ type populateUSAPowertrainCmd struct { settings config.Settings pdb db.Store nhtsaService services.INHTSAService + deviceDefSvc services.DeviceDefinitionService + + useNHTSA bool } func (*populateUSAPowertrainCmd) Name() string { return "populate-usa-powertrain" } func (*populateUSAPowertrainCmd) Synopsis() string { return "populate-usa-powertrain args to stdout." } func (*populateUSAPowertrainCmd) Usage() string { return `populate-usa-powertrain: - populate-usa-powertrain args. + populate-usa-powertrain [-useNHTSA]. ` } // nolint func (p *populateUSAPowertrainCmd) SetFlags(f *flag.FlagSet) { - + f.BoolVar(&p.useNHTSA, "useNHTSA", false, "Use useNHTSA") } func (p *populateUSAPowertrainCmd) Execute(ctx context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { p.logger.Info().Msg("Populating USA powertrain data from VINs") - err := populateUSAPowertrain(ctx, &p.logger, p.pdb, p.nhtsaService) + err := populateUSAPowertrain(ctx, &p.logger, p.pdb, p.nhtsaService, p.deviceDefSvc, p.useNHTSA) if err != nil { p.logger.Fatal().Err(err).Msg("Error filling in powertrain data.") } return subcommands.ExitSuccess } -func populateUSAPowertrain(ctx context.Context, logger *zerolog.Logger, pdb db.Store, nhtsaService services.INHTSAService) error { +func populateUSAPowertrain(ctx context.Context, logger *zerolog.Logger, pdb db.Store, nhtsaService services.INHTSAService, deviceDefSvc services.DeviceDefinitionService, useNHTSA bool) error { + + const ( + PowerTrainType = "powertrain_type" + ) + devices, err := models.UserDevices( models.UserDeviceWhere.CountryCode.EQ(null.StringFrom("USA")), models.UserDeviceWhere.VinIdentifier.IsNotNull(), @@ -53,7 +60,7 @@ func populateUSAPowertrain(ctx context.Context, logger *zerolog.Logger, pdb db.S return err } - process := func(device *models.UserDevice) error { + processFromNTHSA := func(device *models.UserDevice) error { resp, err := nhtsaService.DecodeVIN(device.VinIdentifier.String) if err != nil { return err @@ -78,10 +85,56 @@ func populateUSAPowertrain(ctx context.Context, logger *zerolog.Logger, pdb db.S return nil } + processFromDeviceDefinition := func(device *models.UserDevice) error { + resp, err := deviceDefSvc.GetDeviceDefinitionByID(ctx, device.DeviceDefinitionID) + if err != nil { + return err + } + + md := new(services.UserDeviceMetadata) + if err := device.Metadata.Unmarshal(md); err != nil { + return err + } + + if len(resp.DeviceAttributes) > 0 { + // Find device attribute (powertrain_type) + for _, item := range resp.DeviceAttributes { + if item.Name == PowerTrainType { + + powertrainType, err := deviceDefSvc.ConvertPowerTrainStringToPowertrain(&item.Value) + if err != nil { + return err + } + + md.PowertrainType = &powertrainType + if err := device.Metadata.Marshal(md); err != nil { + return err + } + + break + } + } + } + + if _, err := device.Update(ctx, pdb.DBS().Writer, boil.Infer()); err != nil { + return err + } + return nil + } + for _, device := range devices { - if err := process(device); err != nil { - logger.Err(err).Str("userDeviceId", device.ID).Str("vin", device.VinIdentifier.String).Msg("Failed to update powertrain metadata.") + if useNHTSA { + if err := processFromNTHSA(device); err != nil { + logger.Err(err).Str("userDeviceId", device.ID).Str("vin", device.VinIdentifier.String).Msg("Failed to update powertrain metadata NHTSA.") + } } + + if !useNHTSA { + if err := processFromDeviceDefinition(device); err != nil { + logger.Err(err).Str("userDeviceId", device.ID).Str("vin", device.VinIdentifier.String).Msg("Failed to update powertrain metadata from DeviceDefinition.") + } + } + } return nil diff --git a/internal/controllers/user_devices_controller.go b/internal/controllers/user_devices_controller.go index bbed7b855..338a5a1e7 100644 --- a/internal/controllers/user_devices_controller.go +++ b/internal/controllers/user_devices_controller.go @@ -1061,7 +1061,7 @@ func (udc *UserDevicesController) UpdateVIN(c *fiber.Ctx) error { // TODO: Genericize this for more countries. if userDevice.CountryCode.Valid && userDevice.CountryCode.String == "USA" { - if err := udc.updateUSAPowertrain(c.Context(), userDevice); err != nil { + if err := udc.updateUSAPowertrain(c.Context(), userDevice, false); err != nil { logger.Err(err).Msg("Failed to update American powertrain type.") } } @@ -1069,24 +1069,52 @@ func (udc *UserDevicesController) UpdateVIN(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusNoContent) } -func (udc *UserDevicesController) updateUSAPowertrain(ctx context.Context, userDevice *models.UserDevice) error { +func (udc *UserDevicesController) updateUSAPowertrain(ctx context.Context, userDevice *models.UserDevice, useNHTSA bool) error { + const ( + PowerTrainType = "powertrain_type" + ) + // todo grpc pull vin decoder via grpc from device definitions - resp, err := udc.nhtsaService.DecodeVIN(userDevice.VinIdentifier.String) - if err != nil { + md := new(services.UserDeviceMetadata) + if err := userDevice.Metadata.Unmarshal(md); err != nil { return err } - dt, err := resp.DriveType() - if err != nil { - return err + if useNHTSA { + resp, err := udc.nhtsaService.DecodeVIN(userDevice.VinIdentifier.String) + if err != nil { + return err + } + + dt, err := resp.DriveType() + if err != nil { + return err + } + + md.PowertrainType = &dt } - md := new(services.UserDeviceMetadata) - if err := userDevice.Metadata.Unmarshal(md); err != nil { - return err + if !useNHTSA { + resp, err := udc.DeviceDefSvc.GetDeviceDefinitionByID(ctx, userDevice.DeviceDefinitionID) + if err != nil { + return err + } + + if len(resp.DeviceAttributes) > 0 { + // Find device attribute (powertrain_type) + for _, item := range resp.DeviceAttributes { + if item.Name == PowerTrainType { + powertrainType, err := udc.DeviceDefSvc.ConvertPowerTrainStringToPowertrain(&item.Value) + if err != nil { + return err + } + md.PowertrainType = &powertrainType + break + } + } + } } - md.PowertrainType = &dt if err := userDevice.Metadata.Marshal(md); err != nil { return err } diff --git a/internal/services/device_definitions_service.go b/internal/services/device_definitions_service.go index dd6855e08..66e8efed1 100644 --- a/internal/services/device_definitions_service.go +++ b/internal/services/device_definitions_service.go @@ -47,6 +47,7 @@ type DeviceDefinitionService interface { CreateIntegration(ctx context.Context, integrationType string, vendor string, style string) (*ddgrpc.Integration, error) DecodeVIN(ctx context.Context, vin string, model string, year int, countryCode string) (*ddgrpc.DecodeVinResponse, error) GetIntegrationByTokenID(ctx context.Context, tokenID uint64) (*ddgrpc.Integration, error) + ConvertPowerTrainStringToPowertrain(value *string) (PowertrainType, error) } type deviceDefinitionService struct { @@ -755,3 +756,19 @@ func (d *deviceDefinitionService) getDeviceLatLong(userDeviceID string) (lat, lo } return } + +func (d *deviceDefinitionService) ConvertPowerTrainStringToPowertrain(value *string) (PowertrainType, error) { + if value == nil { + return ICE, nil + } + switch *value { + case "HEV": + return HEV, nil + case "PHEV": + return PHEV, nil + case "BEV": + return BEV, nil + default: + return "", fmt.Errorf("unrecognized electrification level id: %d", value) + } +} From 41a19da6871cd1d82c626b815d892612f4887375 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 15 Aug 2023 00:06:45 -0500 Subject: [PATCH 2/7] Update mocks --- .../mocks/device_definitions_service_mock.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/services/mocks/device_definitions_service_mock.go b/internal/services/mocks/device_definitions_service_mock.go index f317f8f5d..5d7913507 100644 --- a/internal/services/mocks/device_definitions_service_mock.go +++ b/internal/services/mocks/device_definitions_service_mock.go @@ -38,6 +38,21 @@ func (m *MockDeviceDefinitionService) EXPECT() *MockDeviceDefinitionServiceMockR return m.recorder } +// ConvertPowerTrainStringToPowertrain mocks base method. +func (m *MockDeviceDefinitionService) ConvertPowerTrainStringToPowertrain(value *string) (services.PowertrainType, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConvertPowerTrainStringToPowertrain", value) + ret0, _ := ret[0].(services.PowertrainType) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ConvertPowerTrainStringToPowertrain indicates an expected call of ConvertPowerTrainStringToPowertrain. +func (mr *MockDeviceDefinitionServiceMockRecorder) ConvertPowerTrainStringToPowertrain(value interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConvertPowerTrainStringToPowertrain", reflect.TypeOf((*MockDeviceDefinitionService)(nil).ConvertPowerTrainStringToPowertrain), value) +} + // CreateIntegration mocks base method. func (m *MockDeviceDefinitionService) CreateIntegration(ctx context.Context, integrationType, vendor, style string) (*grpc.Integration, error) { m.ctrl.T.Helper() From 698b158986f7f59cf0a81ed2c684d73af69efa2f Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 15 Aug 2023 00:23:57 -0500 Subject: [PATCH 3/7] update test --- .../user_devices_controller_test.go | 22 +++++++++++-------- internal/test/helpers.go | 5 +++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/controllers/user_devices_controller_test.go b/internal/controllers/user_devices_controller_test.go index 4b733fcac..ea4e3383b 100644 --- a/internal/controllers/user_devices_controller_test.go +++ b/internal/controllers/user_devices_controller_test.go @@ -597,15 +597,19 @@ func (s *UserDevicesControllerTestSuite) TestPatchVIN() { s.deviceDefSvc.EXPECT().GetIntegrations(gomock.Any()).Return([]*grpc.Integration{integration}, nil) s.usersClient.EXPECT().GetUser(gomock.Any(), &pb.GetUserRequest{Id: s.testUserID}).Return(&pb.User{Id: s.testUserID, EthereumAddress: nil}, nil) - evID := "4" - s.nhtsaService.EXPECT().DecodeVIN("5YJYGDEE5MF085533").Return(&services.NHTSADecodeVINResponse{ - Results: []services.NHTSAResult{ - { - VariableID: 126, - ValueID: &evID, - }, - }, - }, nil) + //evID := "4" + //s.nhtsaService.EXPECT().DecodeVIN("5YJYGDEE5MF085533").Return(&services.NHTSADecodeVINResponse{ + // Results: []services.NHTSAResult{ + // { + // VariableID: 126, + // ValueID: &evID, + // }, + // }, + //}, nil) + + s.deviceDefSvc.EXPECT().GetDeviceDefinitionByID(gomock.Any(), dd[0].DeviceDefinitionId).Times(1).Return(dd[0], nil) + powerTrainType := "ICE" + s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(gomock.Any()).Times(1).Return(&powerTrainType, nil) payload := `{ "vin": "5YJYGDEE5MF085533" }` request := test.BuildRequest("PATCH", "/user/devices/"+ud.ID+"/vin", payload) response, responseError := s.app.Test(request) diff --git a/internal/test/helpers.go b/internal/test/helpers.go index 5d8a1c898..bbeb0a282 100644 --- a/internal/test/helpers.go +++ b/internal/test/helpers.go @@ -524,6 +524,11 @@ func BuildDeviceDefinitionGRPC(deviceDefinitionID string, mk string, model strin rp.DeviceIntegrations = integrationsToAdd } + rp.DeviceAttributes = append(rp.DeviceAttributes, &ddgrpc.DeviceTypeAttribute{ + Name: "powertrain_type", + Value: "ICE", + }) + return []*ddgrpc.GetDeviceDefinitionItemResponse{rp} } From c3f4aac2ea3ffaf8aabaaa403a7fd42439a8df74 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 15 Aug 2023 09:16:03 -0500 Subject: [PATCH 4/7] Update ConvertPowerTrainStringToPowertrain --- cmd/devices-api/populate_powertrain.go | 7 +------ .../controllers/user_devices_controller.go | 5 +---- .../user_devices_controller_test.go | 2 +- .../services/device_definitions_service.go | 21 ++++++++++--------- .../mocks/device_definitions_service_mock.go | 5 ++--- 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/cmd/devices-api/populate_powertrain.go b/cmd/devices-api/populate_powertrain.go index e2b0ac470..d561e9de1 100644 --- a/cmd/devices-api/populate_powertrain.go +++ b/cmd/devices-api/populate_powertrain.go @@ -100,12 +100,7 @@ func populateUSAPowertrain(ctx context.Context, logger *zerolog.Logger, pdb db.S // Find device attribute (powertrain_type) for _, item := range resp.DeviceAttributes { if item.Name == PowerTrainType { - - powertrainType, err := deviceDefSvc.ConvertPowerTrainStringToPowertrain(&item.Value) - if err != nil { - return err - } - + powertrainType := deviceDefSvc.ConvertPowerTrainStringToPowertrain(item.Value) md.PowertrainType = &powertrainType if err := device.Metadata.Marshal(md); err != nil { return err diff --git a/internal/controllers/user_devices_controller.go b/internal/controllers/user_devices_controller.go index 338a5a1e7..9c60f3639 100644 --- a/internal/controllers/user_devices_controller.go +++ b/internal/controllers/user_devices_controller.go @@ -1104,10 +1104,7 @@ func (udc *UserDevicesController) updateUSAPowertrain(ctx context.Context, userD // Find device attribute (powertrain_type) for _, item := range resp.DeviceAttributes { if item.Name == PowerTrainType { - powertrainType, err := udc.DeviceDefSvc.ConvertPowerTrainStringToPowertrain(&item.Value) - if err != nil { - return err - } + powertrainType := udc.DeviceDefSvc.ConvertPowerTrainStringToPowertrain(item.Value) md.PowertrainType = &powertrainType break } diff --git a/internal/controllers/user_devices_controller_test.go b/internal/controllers/user_devices_controller_test.go index ea4e3383b..10c2507c8 100644 --- a/internal/controllers/user_devices_controller_test.go +++ b/internal/controllers/user_devices_controller_test.go @@ -609,7 +609,7 @@ func (s *UserDevicesControllerTestSuite) TestPatchVIN() { s.deviceDefSvc.EXPECT().GetDeviceDefinitionByID(gomock.Any(), dd[0].DeviceDefinitionId).Times(1).Return(dd[0], nil) powerTrainType := "ICE" - s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(gomock.Any()).Times(1).Return(&powerTrainType, nil) + s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(gomock.Any()).Return(powerTrainType) payload := `{ "vin": "5YJYGDEE5MF085533" }` request := test.BuildRequest("PATCH", "/user/devices/"+ud.ID+"/vin", payload) response, responseError := s.app.Test(request) diff --git a/internal/services/device_definitions_service.go b/internal/services/device_definitions_service.go index 66e8efed1..eae6d337b 100644 --- a/internal/services/device_definitions_service.go +++ b/internal/services/device_definitions_service.go @@ -47,7 +47,7 @@ type DeviceDefinitionService interface { CreateIntegration(ctx context.Context, integrationType string, vendor string, style string) (*ddgrpc.Integration, error) DecodeVIN(ctx context.Context, vin string, model string, year int, countryCode string) (*ddgrpc.DecodeVinResponse, error) GetIntegrationByTokenID(ctx context.Context, tokenID uint64) (*ddgrpc.Integration, error) - ConvertPowerTrainStringToPowertrain(value *string) (PowertrainType, error) + ConvertPowerTrainStringToPowertrain(value string) PowertrainType } type deviceDefinitionService struct { @@ -757,18 +757,19 @@ func (d *deviceDefinitionService) getDeviceLatLong(userDeviceID string) (lat, lo return } -func (d *deviceDefinitionService) ConvertPowerTrainStringToPowertrain(value *string) (PowertrainType, error) { - if value == nil { - return ICE, nil - } - switch *value { +func (d *deviceDefinitionService) ConvertPowerTrainStringToPowertrain(value string) PowertrainType { + switch value { case "HEV": - return HEV, nil + return HEV case "PHEV": - return PHEV, nil + return PHEV case "BEV": - return BEV, nil + return BEV + case "ICE": + return ICE + case "FCEV": + return FCEV default: - return "", fmt.Errorf("unrecognized electrification level id: %d", value) + return ICE } } diff --git a/internal/services/mocks/device_definitions_service_mock.go b/internal/services/mocks/device_definitions_service_mock.go index 5d7913507..579fc47bb 100644 --- a/internal/services/mocks/device_definitions_service_mock.go +++ b/internal/services/mocks/device_definitions_service_mock.go @@ -39,12 +39,11 @@ func (m *MockDeviceDefinitionService) EXPECT() *MockDeviceDefinitionServiceMockR } // ConvertPowerTrainStringToPowertrain mocks base method. -func (m *MockDeviceDefinitionService) ConvertPowerTrainStringToPowertrain(value *string) (services.PowertrainType, error) { +func (m *MockDeviceDefinitionService) ConvertPowerTrainStringToPowertrain(value string) services.PowertrainType { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ConvertPowerTrainStringToPowertrain", value) ret0, _ := ret[0].(services.PowertrainType) - ret1, _ := ret[1].(error) - return ret0, ret1 + return ret0 } // ConvertPowerTrainStringToPowertrain indicates an expected call of ConvertPowerTrainStringToPowertrain. From 3b486f64d1fd1b326e049aaf8146f86195f474ed Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 15 Aug 2023 17:29:40 -0500 Subject: [PATCH 5/7] Fix Test --- internal/controllers/user_devices_controller_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/controllers/user_devices_controller_test.go b/internal/controllers/user_devices_controller_test.go index 10c2507c8..b2687168e 100644 --- a/internal/controllers/user_devices_controller_test.go +++ b/internal/controllers/user_devices_controller_test.go @@ -608,8 +608,7 @@ func (s *UserDevicesControllerTestSuite) TestPatchVIN() { //}, nil) s.deviceDefSvc.EXPECT().GetDeviceDefinitionByID(gomock.Any(), dd[0].DeviceDefinitionId).Times(1).Return(dd[0], nil) - powerTrainType := "ICE" - s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(gomock.Any()).Return(powerTrainType) + s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(gomock.Any()).Times(1).Return(services.BEV) payload := `{ "vin": "5YJYGDEE5MF085533" }` request := test.BuildRequest("PATCH", "/user/devices/"+ud.ID+"/vin", payload) response, responseError := s.app.Test(request) From 84e021ed750f2cbcdfd7280f5c3b42a7cce0b82e Mon Sep 17 00:00:00 2001 From: ricardo Date: Wed, 16 Aug 2023 13:34:07 -0500 Subject: [PATCH 6/7] pass actual powertraintype --- internal/controllers/user_devices_controller_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/controllers/user_devices_controller_test.go b/internal/controllers/user_devices_controller_test.go index b2687168e..3d831e655 100644 --- a/internal/controllers/user_devices_controller_test.go +++ b/internal/controllers/user_devices_controller_test.go @@ -593,6 +593,16 @@ func (s *UserDevicesControllerTestSuite) TestGetMyUserDevicesNoDuplicates() { func (s *UserDevicesControllerTestSuite) TestPatchVIN() { integration := test.BuildIntegrationGRPC(constants.AutoPiVendor, 10, 4) dd := test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Escape", 2020, integration) + + const powertrain_type = "powertrain_type" + powertrainValue := "" + for _, item := range dd[0].DeviceAttributes { + if item.Name == powertrain_type { + powertrainValue = item.Value + break + } + } + ud := test.SetupCreateUserDevice(s.T(), s.testUserID, dd[0].DeviceDefinitionId, nil, "", s.pdb) s.deviceDefSvc.EXPECT().GetIntegrations(gomock.Any()).Return([]*grpc.Integration{integration}, nil) @@ -608,7 +618,7 @@ func (s *UserDevicesControllerTestSuite) TestPatchVIN() { //}, nil) s.deviceDefSvc.EXPECT().GetDeviceDefinitionByID(gomock.Any(), dd[0].DeviceDefinitionId).Times(1).Return(dd[0], nil) - s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(gomock.Any()).Times(1).Return(services.BEV) + s.deviceDefSvc.EXPECT().ConvertPowerTrainStringToPowertrain(powertrainValue).Times(1).Return(services.BEV) payload := `{ "vin": "5YJYGDEE5MF085533" }` request := test.BuildRequest("PATCH", "/user/devices/"+ud.ID+"/vin", payload) response, responseError := s.app.Test(request) From 5bca6fc55914a9cb32613cd4002554a989ed04f2 Mon Sep 17 00:00:00 2001 From: ricardo Date: Wed, 16 Aug 2023 13:37:00 -0500 Subject: [PATCH 7/7] change constant name --- internal/controllers/user_devices_controller_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/controllers/user_devices_controller_test.go b/internal/controllers/user_devices_controller_test.go index 3d831e655..20e9f8635 100644 --- a/internal/controllers/user_devices_controller_test.go +++ b/internal/controllers/user_devices_controller_test.go @@ -594,10 +594,10 @@ func (s *UserDevicesControllerTestSuite) TestPatchVIN() { integration := test.BuildIntegrationGRPC(constants.AutoPiVendor, 10, 4) dd := test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Escape", 2020, integration) - const powertrain_type = "powertrain_type" + const powertrainType = "powertrain_type" powertrainValue := "" for _, item := range dd[0].DeviceAttributes { - if item.Name == powertrain_type { + if item.Name == powertrainType { powertrainValue = item.Value break }