Skip to content

Fix GetLocale test to match OpenAPI specification#87

Merged
jeroenrinzema merged 3 commits intomainfrom
copilot/fix-locale-tests-issue
Dec 1, 2025
Merged

Fix GetLocale test to match OpenAPI specification#87
jeroenrinzema merged 3 commits intomainfrom
copilot/fix-locale-tests-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 1, 2025

The GetLocale test was incorrectly expecting the response to be wrapped in a "data" field, causing test failures:

Error: json: cannot unmarshal string into Go value of type oapi.Locale

Changes

  • services/nexus/internal/http/controllers/v1/locales_test.go: Fixed test to expect Locale object directly instead of wrapped in a "data" field

The OpenAPI specification at services/nexus/oapi/resources.yml defines the GetLocale endpoint response as:

responses:
  '200':
    description: Locale retrieved successfully
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/Locale'

This clearly indicates the response should be a Locale object directly, not wrapped in a data field. The test has been updated to align with this specification.

Testing

  • ✅ All locale tests passing (TestGetLocale/get_by_id, TestGetLocale/get_by_key, TestGetLocale/not_found)

  • ✅ Code compiles successfully

  • ✅ CodeQL security check passed

  • Fixes Locale tests are failing #86

Original prompt

This section details on the original issue you should resolve

<issue_title>Locale tests are failing</issue_title>
<issue_description>The locale tests are failing.

--- FAIL: TestGetLocale (0.29s)
    logger.go:146: 2025-12-01T17:01:33.753+0100 INFO    getting locale  {"project_id": "43d7f034-dc6b-4c44-9c1b-e29b86291a6c", "locale_id": "en"}
    --- FAIL: TestGetLocale/get_by_key (0.00s)
        locales_test.go:234: 
                Error Trace:    /Users/jeroen/Documents/github.com/lunogram/platform/services/nexus/internal/http/controllers/v1/locales_test.go:234
                Error:          Received unexpected error:
                                json: cannot unmarshal string into Go value of type oapi.Locale
                Test:           TestGetLocale/get_by_key
    logger.go:146: 2025-12-01T17:01:33.755+0100 INFO    getting locale  {"project_id": "43d7f034-dc6b-4c44-9c1b-e29b86291a6c", "locale_id": "69699482-9e05-4771-9895-028c77d7a37d"}
    --- FAIL: TestGetLocale/get_by_id (0.00s)
        locales_test.go:234: 
                Error Trace:    /Users/jeroen/Documents/github.com/lunogram/platform/services/nexus/internal/http/controllers/v1/locales_test.go:234
                Error:          Received unexpected error:
                                json: cannot unmarshal string into Go value of type oapi.Locale
                Test:           TestGetLocale/get_by_id
    logger.go:146: 2025-12-01T17:01:33.756+0100 INFO    getting locale  {"project_id": "43d7f034-dc6b-4c44-9c1b-e29b86291a6c", "locale_id": "57936901-55d6-4e70-a2b8-058ac8b162de"}
    logger.go:146: 2025-12-01T17:01:33.757+0100 ERROR   locale not found        {"project_id": "43d7f034-dc6b-4c44-9c1b-e29b86291a6c", "locale_id": "57936901-55d6-4e70-a2b8-058ac8b162de", "locale_id": "57936901-55d6-4e70-a2b8-058ac8b162de"}
FAIL
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing locale tests Fix GetLocale response format to match API convention Dec 1, 2025
Copilot AI requested a review from jeroenrinzema December 1, 2025 16:14
Comment on lines +159 to +161
json.Write(w, http.StatusOK, map[string]interface{}{
"data": locale.OAPI(),
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the locale OAPI should not be returned in a data object. Please update the OpenAPI specs if needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 06c7f04. Reverted the controller to return the locale directly (matching the OpenAPI spec) and updated the test to expect the Locale object without the "data" wrapper.

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Copilot AI changed the title Fix GetLocale response format to match API convention Fix GetLocale test to match OpenAPI specification Dec 1, 2025
Copilot AI requested a review from jeroenrinzema December 1, 2025 16:34
@jeroenrinzema jeroenrinzema marked this pull request as ready for review December 1, 2025 16:34
@jeroenrinzema jeroenrinzema merged commit 00eca92 into main Dec 1, 2025
3 checks passed
@jeroenrinzema jeroenrinzema deleted the copilot/fix-locale-tests-issue branch December 1, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Locale tests are failing

2 participants