From f2ae43d37b8d57ee054d7809cadfb8f563073da0 Mon Sep 17 00:00:00 2001 From: Luis Oliveira Date: Sat, 21 Mar 2026 04:19:26 +0000 Subject: [PATCH] GetConfigURLsFromVIN fixing response structure --- .../controllers/device_config_controller.go | 4 +--- .../device_config_controller_test.go | 18 +++++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/internal/controllers/device_config_controller.go b/internal/controllers/device_config_controller.go index fbc6209..5a40247 100644 --- a/internal/controllers/device_config_controller.go +++ b/internal/controllers/device_config_controller.go @@ -535,9 +535,7 @@ func (d *DeviceConfigController) GetConfigURLsFromVIN(c *fiber.Ctx) error { } resp.DeviceSettingURL = fmt.Sprintf("%s/v1/device-config/settings/%s@%s", d.settings.DeploymentURL, deviceSetting.Name, deviceSetting.Version) - return c.JSON(DeviceTemplateStatusResponse{ - Template: resp, - }) + return c.JSON(resp) } func parseOutTemplateAndVersion(templateNameWithVersion string) (string, string) { diff --git a/internal/controllers/device_config_controller_test.go b/internal/controllers/device_config_controller_test.go index 45d9648..7939ae6 100644 --- a/internal/controllers/device_config_controller_test.go +++ b/internal/controllers/device_config_controller_test.go @@ -438,13 +438,15 @@ func (s *DeviceConfigControllerTestSuite) TestGetConfigURLsFromVIN_DefaultTempla require.Equal(s.T(), fiber.StatusOK, response.StatusCode) body, _ := io.ReadAll(response.Body) - var receivedResp DeviceTemplateStatusResponse + s.T().Logf("RAW JSON:\n%s", string(body)) + + var receivedResp device.ConfigResponse err = json.Unmarshal(body, &receivedResp) require.NoError(s.T(), err) - assert.Equal(s.T(), "http://localhost:3000/v1/device-config/pids/default-ice-can11@v1.2.3", receivedResp.Template.PidURL) - assert.Equal(s.T(), "http://localhost:3000/v1/device-config/dbc/default-ice-can11@v1.2.3", receivedResp.Template.DbcURL) - assert.Equal(s.T(), "http://localhost:3000/v1/device-config/settings/default-ice@v9.9.9", receivedResp.Template.DeviceSettingURL) + assert.Equal(s.T(), "http://localhost:3000/v1/device-config/pids/default-ice-can11@v1.2.3", receivedResp.PidURL) + assert.Equal(s.T(), "http://localhost:3000/v1/device-config/dbc/default-ice-can11@v1.2.3", receivedResp.DbcURL) + assert.Equal(s.T(), "http://localhost:3000/v1/device-config/settings/default-ice@v9.9.9", receivedResp.DeviceSettingURL) } func (s *DeviceConfigControllerTestSuite) TestGetConfigURLsFromVIN_ProtocolOverrideQS() { @@ -473,12 +475,14 @@ func (s *DeviceConfigControllerTestSuite) TestGetConfigURLsFromVIN_ProtocolOverr require.Equal(s.T(), fiber.StatusOK, response.StatusCode) body, _ := io.ReadAll(response.Body) - var receivedResp DeviceTemplateStatusResponse + s.T().Logf("RAW JSON:\n%s", string(body)) + + var receivedResp device.ConfigResponse err = json.Unmarshal(body, &receivedResp) require.NoError(s.T(), err) - assert.Equal(s.T(), "http://localhost:3000/v1/device-config/pids/default-ice-can29@v2.0.0", receivedResp.Template.PidURL) - assert.Equal(s.T(), "http://localhost:3000/v1/device-config/settings/default-ice@v1.0.0", receivedResp.Template.DeviceSettingURL) + assert.Equal(s.T(), "http://localhost:3000/v1/device-config/pids/default-ice-can29@v2.0.0", receivedResp.PidURL) + assert.Equal(s.T(), "http://localhost:3000/v1/device-config/settings/default-ice@v1.0.0", receivedResp.DeviceSettingURL) } func (s *DeviceConfigControllerTestSuite) TestGetConfigStatusByEthAddr_DeviceDataOnly() {