feature: sort imports to try to ensure parameter paths are less specific
This commit is contained in:
parent
c92ef0688b
commit
4f68a64a88
4 changed files with 72 additions and 10 deletions
35
tests/07_test_route_sorting.test.ts
Normal file
35
tests/07_test_route_sorting.test.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import * as asserts from '@std/assert';
|
||||
import { EPHEMERAL_SERVER, get_ephemeral_listen_server } from './helpers.ts';
|
||||
|
||||
Deno.test({
|
||||
name: 'test that routes are sorted most to least specific',
|
||||
permissions: {
|
||||
env: true,
|
||||
read: true,
|
||||
write: true,
|
||||
net: true
|
||||
},
|
||||
fn: async () => {
|
||||
let test_server_info: EPHEMERAL_SERVER | null = null;
|
||||
|
||||
try {
|
||||
Deno.env.set('SERVERUS_ROOT', './tests/www');
|
||||
test_server_info = await get_ephemeral_listen_server();
|
||||
|
||||
const response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/echo/hi`, {
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
const body = await response.text();
|
||||
|
||||
asserts.assert(response.ok);
|
||||
asserts.assert(body);
|
||||
asserts.assertEquals(body, 'hello');
|
||||
} finally {
|
||||
Deno.env.delete('SERVERUS_ROOT');
|
||||
if (test_server_info) {
|
||||
await test_server_info?.server?.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
8
tests/www/echo/hi/index.ts
Normal file
8
tests/www/echo/hi/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export function GET(_req: Request, _meta: Record<string, any>): Response {
|
||||
return new Response('hello', {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue