-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add [GitLab] Top Language Badge #10750
Add [GitLab] Top Language Badge #10750
Conversation
|
Closes #10181 |
Pending: Test cases |
Need help handling case where the API returns an empty object. Happens when the repository has no code. Only markdown? |
I'll hold off on a proper review until you've got some tests. You've said:
Broadly there are two patterns we can use here: One is to write the Joi schema such that this response is rejected and just accept that this case will throw the generic validation error message. The other pattern is you can write the schema such that this response is allowed and throw an If you're still struggling, can you post an example of a repo or API call that has the problem you're trying to handle. |
Test cases added. |
https://gitlab.com/api/v4/projects/KoruptTinker%2Fgitlab-blank-repo/languages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Couple of comments. Aside from those, this is in good shape.
} else { | ||
return { | ||
label: 'no languages found', | ||
message: 'NA', | ||
color: 'blue', | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we
throw new InvalidResponse({ prettyMessage: 'no languages found' })
here and update the test.
const schema = Joi.object() | ||
.pattern(Joi.string(), Joi.number().min(0).max(100).precision(2)) | ||
.required() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The object key and value should both be .required()
, so
const schema = Joi.object() | |
.pattern(Joi.string(), Joi.number().min(0).max(100).precision(2)) | |
.required() | |
const schema = Joi.object() | |
.pattern( | |
Joi.string().required(), | |
Joi.number().min(0).max(100).precision(2).required(), | |
) | |
.required() |
here
Requested changes made. |
🚀 Updated review app: https://pr-10750-badges-shields.fly.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thanks 👍
No description provided.