Skip to content

Commit 2d259b6

Browse files
committed
Fix our tests and checks
1 parent b52aec2 commit 2d259b6

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

cors-proxy/src/index.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { describe, it, expect, vi } from 'vitest'
22
import app from './index'
33

4+
vi.mock('./verify-head-commit', () => ({
5+
verifyHeadCommit: vi.fn(async () => null),
6+
}))
7+
48
async function sha256Hex(input: string): Promise<string> {
59
const encoded = new TextEncoder().encode(input)
610
const hashBuffer = await crypto.subtle.digest('SHA-256', encoded)
@@ -13,16 +17,18 @@ async function gzip(data: string): Promise<ArrayBuffer> {
1317
return new Response(compressed).arrayBuffer()
1418
}
1519

20+
const validCommit = 'a'.repeat(40)
21+
1622
function makeEntry(repoUrl = 'https://github.com/owner/repo') {
1723
return {
1824
version: 1,
1925
repoUrl,
20-
headCommit: 'abc123',
26+
headCommit: validCommit,
2127
result: {
2228
repoUrl,
2329
defaultBranch: 'main',
2430
analyzedAt: '2025-01-01T00:00:00Z',
25-
headCommit: 'abc123',
31+
headCommit: validCommit,
2632
detectedLanguages: [],
2733
days: [],
2834
},
@@ -147,7 +153,7 @@ describe('PUT /cache/v1/:repoHash', () => {
147153
{ RESULTS: bucket },
148154
)
149155
expect(res.status).toBe(400)
150-
expect(await res.text()).toContain('Invalid cache entry shape')
156+
expect(await res.text()).toContain('version must be 1')
151157
})
152158

153159
it('rejects hash mismatch', async () => {
@@ -163,7 +169,7 @@ describe('PUT /cache/v1/:repoHash', () => {
163169
{ RESULTS: bucket },
164170
)
165171
expect(res.status).toBe(400)
166-
expect(await res.text()).toContain('hash does not match')
172+
expect(await res.text()).toContain('repoUrl hash does not match')
167173
})
168174

169175
it('stores valid entry and returns 200', async () => {

cors-proxy/vitest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { defineConfig } from 'vitest/config'
22

33
export default defineConfig({
4+
esbuild: {
5+
tsconfigRaw: '{}',
6+
},
47
test: {
58
include: ['src/**/*.test.ts'],
69
},

0 commit comments

Comments
 (0)