add new unit test, fix minor bugs

This commit is contained in:
ading2210 2024-03-20 02:34:40 -04:00
parent f8e55ea307
commit 1730e6d964
7 changed files with 30 additions and 2 deletions

View file

@ -3,5 +3,6 @@ async function test() {
for (let i=0; i<20; i++) {
let r = await libcurl.fetch("https://example.com/");
assert(r.status === 200, "wrong status");
await r.text();
}
}

View file

@ -1,4 +1,5 @@
async function test() {
let r = await libcurl.fetch("https://example.com/");
assert(r.status === 200, "wrong status");
await r.text();
}

View file

@ -2,7 +2,10 @@ async function test() {
await libcurl.fetch("https://www.example.com/");
let promises = [];
for (let i=0; i<10; i++) {
promises.push(libcurl.fetch("https://www.example.com/"))
promises.push((async ()=>{
let r = await libcurl.fetch("https://www.example.com/");
await r.text();
})())
}
await Promise.all(promises);
}

View file

@ -0,0 +1,19 @@
async function test() {
let sessions = [];
for (let i=0; i<5; i++) {
sessions.push(new libcurl.HTTPSession());
}
let promises = [];
for (let session of sessions) {
promises.push((async ()=>{
let r = await session.fetch("https://www.example.com/");
await r.text();
})());
}
await Promise.all(promises);
for (let session of sessions) {
session.close();
}
}