-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix: quirks with version commands and config retrieval #423
Conversation
.delete(`/api/v1/version/${version}`) | ||
.basicAuth({ user: key }) | ||
.reply(200) | ||
.reply(200, { removed: true }) |
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.
Added {removed: true}
because that's what we return in our API and the handleRes
handler was failing without this because .reply(200)
by itself doesn't return JSON for res.json()
.
We should probably actually return a 204 No Content instead for these delete calls but 🤷
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.
Looking good, just a few test bed suggestions below!
__tests__/cmds/login.test.js
Outdated
@@ -15,28 +15,27 @@ describe('rdme login', () => { | |||
}); | |||
|
|||
it('should error if email is invalid', () => { | |||
expect.assertions(1); | |||
return expect(cmd.run({ project: 'subdomain', email: 'this-is-not-an-email' })).rejects.toThrow( |
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.
I'm a little lukewarm on using toThrow
when we can use toBe(new Error('msg'))
since toThrow
only checks for substrings in error messages (see docs)... but we can leave that as out-of-scope for this PR!
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.
I've always had the worst trouble with toBe(new Error('msg'))
:
● rdme login › should error if no project provided
expect(received).rejects.toBe(expected) // Object.is equality
If it should pass with deep equality, replace "toBe" with "toStrictEqual"
Expected: [Error: No project subdomain provided. Please use `--project`.]
Received: serializes to the same string
17 |
18 | it('should error if no project provided', () => {
> 19 | return expect(cmd.run({})).rejects.toBe(new Error('No project subdomain provided. Please use `--project`.'));
| ^
20 | });
21 |
22 | it('should error if email is invalid', () => {
at Object.toBe (node_modules/expect/build/index.js:285:22)
at Object.<anonymous> (__tests__/cmds/login.test.js:19:40)
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.
oh whooops sorry it definitely should be toStrictEqual
, but I think that's the only issue there?
@kanadgupta I pushed up a bunch of changes if you want to give this another look |
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.
Sorry, I saw a few more places where we could be using toStrictEqual
(assuming it works properly) and just noticed a few areas where we could enhance our tests... but other than that, LGTM!
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
Co-authored-by: Kanad Gupta <[email protected]>
🧰 Changes
While tinkering around with Typescript here I discovered a few quirks:
versions:delete
would never properly alert you if your deletion failed, and our tests to check for this weren't actually testing it.config.host
so I've updated allconfig.*
retrievals to use the preferrable.get()
accessor.🧬 QA & Testing