-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
test: Add test to set custom object ID #9137
Conversation
Thanks for opening this pull request! |
spec/ParseObject.spec.js
Outdated
@@ -12,6 +12,7 @@ | |||
// single-instance mode and we don't want these tests to run in | |||
// single-instance mode. | |||
|
|||
const Parse = require('parse/node'); |
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.
This should not be necessary. There surely are existing tests with custom obj ID?
@mtrezza The test passed. only add
I do not know why. I have set
|
spec/ParseObject.spec.js
Outdated
|
||
const body = { | ||
name: 'SaveAudio', | ||
data: '{"objectId":"66541dbdffead844f1339e3c","createdAt":"2024-05-27T05:44:29.504Z","updatedAt":"2024-05-27T05:44:29.504Z"}', |
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.
Why are you setting the createdAt date here? Could you just create a new object, set a custom object Id and save it, without parsing a JSON. Remember, a test should be as simple as possible to demonstrate the issue.
spec/ParseObject.spec.js
Outdated
const testObject = new Parse.Object(name); | ||
testObject.id = data.objectId; | ||
|
||
const entries = Object.entries(data); |
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.
Also here, the loop is unnecessary, and you don't need to set and field of the object at all. This is about setting a custom ID. So all this extra code should be removed.
spec/ParseObject.spec.js
Outdated
} | ||
|
||
console.log(testObject.toJSON()); | ||
await testObject.save(null, { useMasterKey: 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.
At the end of the test you may want to fetch the object by the custom ID to ensure it has been created correctly in the DB.
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
So the test passes. If you are unable to adapt this test to fail, we have to consider it an issue that is specific to your deployment (custom Cloud Code, triggers, etc). We'd still merge the PR to have this test. |
Closing as no further response |
Pull Request
Issue
Closes: #9134
Approach
Can not custom objectId with parse/node
Tasks