-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_script.js
More file actions
26 lines (22 loc) · 809 Bytes
/
Copy pathtest_script.js
File metadata and controls
26 lines (22 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
async function runTest() {
const response = await fetch('http://localhost:3000/test', {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
if (response.ok) {
const dest = path.join(__dirname, 'file_structure_test.zip');
const fileStream = fs.createWriteStream(dest);
await new Promise((resolve, reject) => {
response.body.pipe(fileStream);
response.body.on('error', reject);
fileStream.on('finish', resolve);
});
console.log('Test zip file downloaded successfully.');
} else {
console.log('Failed to generate test zip file.');
}
}
runTest().catch(err => console.error(err));