Skip to content

add tests for GetAvailableLanguages handler - #103

Merged
andrewtavis merged 5 commits into
scribe-org:mainfrom
ashb155:test/get-available-languages-handler
Oct 5, 2026
Merged

andrewtavis merged 5 commits into
scribe-org:mainfrom
ashb155:test/get-available-languages-handler

Conversation

@ashb155

@ashb155 ashb155 commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Contributor checklist

  • This pull request is on a separate branch and not the main branch
  • I have ran the ./pre-commit executable as well as make lint and have fixed all reported issues

Description

Adds unit tests for the GetAvailableLanguages HTTP handler (GET /api/v1/languages) using net/http/httptest

Test Scenarios Covered

  1. 200 OK with populated array: Tests successful retrieval and formatting of multiple languages with their associated data types.
  2. 500 Internal Server Error: Tests the error path when GetAvailableLanguages fails.
  3. Partial-failure path: Tests that an individual language failing GetLanguageDataTypes is gracefully skipped rather than failing the entire request.

Coverage

  • api/handlers: 5.3% -> 11.9%

Related Issue

Closes #84

@DeleMike DeleMike left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reviewing...

@DeleMike DeleMike left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks again @ashb155 , all looks good to me!

@DeleMike

DeleMike commented Oct 4, 2026

Copy link
Copy Markdown
Member

cc: @andrewtavis you can approve and merge anytime :)

@DeleMike
DeleMike requested a review from andrewtavis October 4, 2026 17:48
@DeleMike

DeleMike commented Oct 4, 2026

Copy link
Copy Markdown
Member

adding some new changes concerning the new profanity and propositions...

@ashb155

ashb155 commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

thank you for the review and additions @DeleMike !

@DeleMike DeleMike left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, I wanted to update the endpoint to ensure that we now have preopositions and profanity count as part of the language-stats endpoint.

@DeleMike

DeleMike commented Oct 4, 2026

Copy link
Copy Markdown
Member

You can check this out @andrewtavis

We now have:

[
  {
    "code": "de",
    "language_name": "German",
    "nouns": 178751,
    "verbs": 23,
    "prepositions": 196,
    "profanity": 113
  },
  {
    "code": "en",
    "language_name": "English",
    "nouns": 33498,
    "verbs": 8787,
    "prepositions": null,
    "profanity": 85
  },
  {
    "code": "es",
    "language_name": "Spanish",
    "nouns": 28022,
    "verbs": 8572,
    "prepositions": null,
    "profanity": 16
  },
  {
    "code": "fr",
    "language_name": "French",
    "nouns": 12769,
    "verbs": 5966,
    "prepositions": null,
    "profanity": 12
  },
  {
    "code": "it",
    "language_name": "Italian",
    "nouns": 33333,
    "verbs": 7667,
    "prepositions": null,
    "profanity": 32
  },
  {
    "code": "pt",
    "language_name": "Portuguese",
    "nouns": 2634,
    "verbs": 509,
    "prepositions": null,
    "profanity": 182
  },
  {
    "code": "ru",
    "language_name": "Russian",
    "nouns": 101217,
    "verbs": 12,
    "prepositions": 27,
    "profanity": 10
  },
  {
    "code": "sv",
    "language_name": "Swedish",
    "nouns": 39767,
    "verbs": 5102,
    "prepositions": null,
    "profanity": 61
  }
]

@andrewtavis andrewtavis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

double praise: All of this looks amazing, @ashb155 and @DeleMike! Thank you both for the tests, features and the collaboration here! 💙

@andrewtavis
andrewtavis merged commit e6d205e into scribe-org:main Oct 5, 2026
3 checks passed
@ashb155
ashb155 deleted the test/get-available-languages-handler branch October 6, 2026 13:52
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.

Add handler tests for GET /api/v1/languages

3 participants