-
Notifications
You must be signed in to change notification settings - Fork 14
tests: add tests for project #45
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
tests: add tests for project #45
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.
I've added the tests. Have a look at these comments :)
src/tasks/index.ts
Outdated
let result | ||
try { | ||
// Setup RUNBOX | ||
await scenario.setup(currentJobDir, job) | ||
|
||
// Run worker | ||
await scenario.run(currentJobDir, job) | ||
// Run worker | ||
await scenario.run(currentJobDir, job) | ||
|
||
// Get result | ||
const result = await scenario.result(currentJobDir, job) | ||
// Get result | ||
result = await scenario.result(currentJobDir, job) | ||
} | ||
catch(err) { | ||
result = { | ||
id: job.id, | ||
stderr: err | ||
} |
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.
What do you think of this try
catch
block. Earlier if there was any error in the code, the code would break and server would stop. So I think try
catch
is required
There is one problem with returning only id
and stderr
. The judge-api-queue-logic will fail and it will always think that this is run_result
event
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.
We do have an error queue mechanism so won't be needing try catch here
test/project/project.nodejs.spec.ts
Outdated
it('should not break when url is invalid', async () => { | ||
const projectResult = await execute(new ProjectJob({ | ||
id: 25, | ||
source: 'https://www.invalidurl.com', | ||
problem: 'https://www.invalidurl.com', | ||
submissionDirs: 'src/*', | ||
lang: 'nodejs', | ||
timelimit: 20, | ||
scenario: 'project' | ||
})) | ||
expect(projectResult).to.have.keys( | ||
'id', | ||
'stderr', | ||
) | ||
}) |
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 the case when the code was breaking. Because this url will pass the validator
of judge-api
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.
Basically we should expect execute function to throw an error
test/project/project.nodejs.spec.ts
Outdated
it('should not break if lang is incorrect', async () => { | ||
const projectResult = await execute(new ProjectJob({ | ||
id: 25, | ||
source: 'https://minio.cb.lk/public/problem.zip', | ||
problem: 'https://minio.cb.lk/public/solution.zip', | ||
submissionDirs: 'src/*', | ||
lang: 'abcd', | ||
timelimit: 20, | ||
scenario: 'project' | ||
})) | ||
|
||
expect(projectResult).to.have.keys( | ||
'id', | ||
'stderr', | ||
) | ||
}) |
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 won't be happening. Lang can't be incorrect. Because it's been checked in the validator. But it's better to be safe :)
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.
We don't have a clear way of reporting wrong lang error in taskmaster. Let's skip as of now
c0ede84
to
5f364bb
Compare
Congratualtions @prabalsingh24, your pull request is merged! 🎉 Thanks for your contributions and participating in BOSS 2020. 🙌 You can claim your bounty points here. 💰 |
ProjectScenario
NodeJSProject