Skip to content

Commit 4593412

Browse files
committed
Update code execution
1 parent b431b11 commit 4593412

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

backend/code-execution-service/src/controllers/codeExecutionControllers.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ export const executeCode = async (req: Request, res: Response) => {
4141
try {
4242
// Get question test case files
4343
const qnsResponse = await questionService.get(`/${questionId}`);
44-
const { testcaseInputFileUrl, testcaseOutputFileUrl } =
44+
const { inputs: stdinList, outputs: expectedResultList } =
4545
qnsResponse.data.question;
4646

4747
// Extract test cases from input and output files
48-
const testCases = await testCasesApi(
49-
testcaseInputFileUrl,
50-
testcaseOutputFileUrl
51-
);
48+
// const testCases = await testCasesApi(
49+
// testcaseInputFileUrl,
50+
// testcaseOutputFileUrl
51+
// );
5252

53-
const stdinList: string[] = testCases.input;
54-
const expectedResultList: string[] = testCases.output;
53+
// const stdinList: string[] = testCases.input;
54+
// const expectedResultList: string[] = testCases.output;
5555

5656
if (stdinList.length !== expectedResultList.length) {
5757
res.status(400).json({

backend/code-execution-service/tests/codeExecutionRoutes.spec.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,12 @@ describe("Code execution routes", () => {
5757
(questionService.get as jest.Mock).mockResolvedValue({
5858
data: {
5959
question: {
60-
testcaseInputFileUrl: "https://peerprep.com/input",
61-
testcaseOutputFileUrl: "https://peerprep.com/output",
60+
inputs: ["1", "2"],
61+
outputs: ["1"],
6262
},
6363
},
6464
});
6565

66-
(testCasesApi as jest.Mock).mockResolvedValue({
67-
input: ["1", "2"],
68-
output: ["1"],
69-
});
70-
7166
const response = await request.post(`${BASE_URL}/run`).send({
7267
language: "python",
7368
code: "print('Hello, world!')",
@@ -81,23 +76,20 @@ describe("Code execution routes", () => {
8176
(questionService.get as jest.Mock).mockResolvedValue({
8277
data: {
8378
question: {
84-
testcaseInputFileUrl: "https://peerprep.com/input",
85-
testcaseOutputFileUrl: "https://peerprep.com/output",
79+
inputs: ["1", "2"],
80+
outputs: ["1", "2"],
8681
},
8782
},
8883
});
8984

90-
(testCasesApi as jest.Mock).mockResolvedValue({
91-
input: ["1", "2"],
92-
output: ["1", "4"],
93-
});
94-
9585
const response = await request.post(`${BASE_URL}/run`).send({
9686
language: "python",
9787
code: "print(input())",
9888
questionId: "1234",
9989
});
10090

91+
console.log(response.body);
92+
10193
expect(response.status).toBe(200);
10294
expect(response.body.message).toBe(SUCCESS_MESSAGE);
10395
expect(response.body.data).toBeInstanceOf(Array);

0 commit comments

Comments
 (0)