-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add message endpoint, implement e2e test #4
Conversation
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 is awesome! The pgboss did exactly what I wanted: use jsonb to store the message, so in this way, in the future, we can query the message by filter easily, this is important to us.
__tests__/e2e/message.spec.js
Outdated
it( | ||
'message/', | ||
async () => { | ||
const response = await supertest(app).post('/message').send({jobName: 'add-tree-test', payload: {treeId: '0101010101'}}); | ||
expect(response.status).toBe(200); // eslint-disable-line | ||
expect(response.body.job.name).toEqual('add-tree-test'); // eslint-disable-line | ||
expect(response.body.job.data).toMatchObject({ // eslint-disable-line | ||
treeId: '0101010101' | ||
}) | ||
}, | ||
1000 * 30 | ||
) | ||
}) |
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.
@dagmawig please test the receiving, that is to say, you should subscribe the message queue name: 'add-tree-test' and make sure the message that you sent is received by the client.
like this:
it('test', done => {
const client = new pgboss.client();
client.subscribe('add-tree-test', data => {
expect(data).toMatchObject({message:'ssss'});
done();
});
// do the post
}}
@dadiorchen I have replaced pg-boss with postgres listen-notify client system. For the e-2-e test I have created two separate pg clients and confirmed they both receive the notification of record insertion. We can add more functionalities in separate PRs later but I believe this will take care of the need for a proof of concept. Please review and let me know what you think. |
working on issue #2
Add
DATABASE_URL
to .env file and runtest-e2e
script to do the message test.The test sends a job to a queue with a
job name
andpayload
and fetches the job afterwards to confirm the job created.The job is found in
pgboss
schema underjob
table.