You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(openapi): error handling for incorrect project and version flags (#411)
* test: fix version creation flow in nock
It doesn't make sense that the API would return v1.0.1 if that's the version the user is trying to create! So this fixes that. The test still passes ¯\_(ツ)_/¯
* fix: properly bubble up errors finding versions
also add a couple tests
* refactor: get rid of unnecessary catch statement
This is being caught by the caller function, so this isn't necessary. Also the tests yield the same result.
* refactor: another place with unnecessary catch statements
Tests still pass, so I think we're good here.
it.todo('should return a 404 if version flag not found');
193
+
it('should error if version flag sent to API returns a 404',async()=>{
194
+
constinvalidVersion='v1000';
195
+
196
+
consterrorObject={
197
+
error: 'VERSION_NOTFOUND',
198
+
message: `The version you specified (${invalidVersion}) doesn't match any of the existing versions (1.0) in ReadMe.`,
199
+
suggestion:
200
+
'You can pass the version in via the `x-readme-version` header. If you want to create a new version, do so in the Versions section inside ReadMe. Note that the version in the URL is our API version, not the version of your docs.',
201
+
docs: 'https://docs.readme.com/logs/xx-xx-xx',
202
+
help: "If you need help, email support@readme.io and include the following link to your API log: 'https://docs.readme.com/logs/xx-xx-xx'.",
).rejects.toThrow('No project API key provided. Please use `--key`.');
257
286
});
258
287
288
+
it('should error if invalid API key is sent and version list does not load',async()=>{
289
+
consterrorObject={
290
+
error: 'APIKEY_NOTFOUND',
291
+
message: "We couldn't find your API key.",
292
+
suggestion:
293
+
"The API key you passed in (API_KEY) doesn't match any keys we have in our system. API keys must be passed in as the username part of basic auth. You can get your API key in Configuration > API Key, or in the docs.",
294
+
docs: 'https://docs.readme.com/logs/xx-xx-xx',
295
+
help: "If you need help, email support@readme.io and include the following link to your API log: 'https://docs.readme.com/logs/xx-xx-xx'.",
0 commit comments