-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ce7a61
commit f28fad0
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Build Registry | ||
run: npm run build | ||
|
||
- name: Run Test | ||
env: | ||
R2_HOSTNAME: ${{ secrets.TEST_R2_HOSTNAME }} | ||
S3_ACCESS_KEY_ID: ${{ secrets.TEST_S3_ACCESS_KEY_ID }} | ||
S3_BUCKET: ${{ secrets.TEST_S3_BUCKET }} | ||
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} | ||
S3_SECRET_ACCESS_KEY: ${{ secrets.TEST_S3_SECRET_ACCESS_KEY }} | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import assert from 'node:assert' | ||
import test from 'node:test' | ||
|
||
async function fetchStr(url) { | ||
const res = await fetch(url) | ||
|
||
if (!res.ok) { | ||
await res.body.cancel() | ||
|
||
return null | ||
} | ||
|
||
return await res.text() | ||
} | ||
|
||
async function fetchJson(url) { | ||
const res = await fetch(url) | ||
|
||
if (!res.ok) { | ||
await res.body.cancel() | ||
|
||
return null | ||
} | ||
|
||
return await res.json() | ||
} | ||
|
||
test('latest tag', async () => { | ||
const latestTag = (await fetchJson('https://api.github.com/repos/esbuild/deno-esbuild/tags'))[0].name | ||
|
||
const res = await fetch('http://localhost:3000/esbuild/deno-esbuild/mod.js', { | ||
redirect: 'manual' | ||
}) | ||
|
||
await res.body.cancel() | ||
|
||
assert.strictEqual(res.headers.get('location', `https://deno.re/esbuild/deno-esbuild@${latestTag}/mod.js`), expected) | ||
}) | ||
|
||
test('specific commit', async () => { | ||
const actual = await fetchStr('http://localhost:3000/esbuild/deno-esbuild@d4ebc0f33d39d5b8cc94eec4b1a94ce5b388cd6f/mod.js') | ||
const expected = await fetchStr('https://raw.githubusercontent.com/esbuild/deno-esbuild/d4ebc0f33d39d5b8cc94eec4b1a94ce5b388cd6f/mod.js') | ||
|
||
assert.strictEqual(actual, expected) | ||
}) | ||
|
||
test('specific tag', async () => { | ||
const actual = await fetchStr('http://localhost:3000/esbuild/[email protected]/mod.js') | ||
const expected = await fetchStr('https://raw.githubusercontent.com/esbuild/deno-esbuild/v0.19.0/mod.js') | ||
|
||
assert.strictEqual(actual, expected) | ||
}) | ||
|
||
test('omit entry point', async () => { | ||
const actual = await fetchStr('http://localhost:3000/esbuild/[email protected]') | ||
const expected = await fetchStr('https://raw.githubusercontent.com/esbuild/deno-esbuild/v0.20.0/mod.js') | ||
|
||
assert.strictEqual(actual, expected) | ||
}) | ||
|
||
test('type header', async () => { | ||
const res = await fetch('http://localhost:3000/esbuild/[email protected]/mod.js') | ||
|
||
await res.body.cancel() | ||
|
||
assert.strictEqual(res.headers.get('x-typescript-types'), `https://deno.re/esbuild/[email protected]/mod.d.ts`) | ||
}) |