mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* oom(01): A1-shared-readers — reintroduce #10179 subset Files: 18 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(02): A2-shared-image-media — reintroduce #10179 subset Files: 7 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(03): A3-shared-fs-listing — reintroduce #10179 subset Files: 21 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(04): A4-shared-remote-relay — reintroduce #10179 subset Files: 8 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(05): A5-shared-misc — reintroduce #10179 subset Files: 28 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(06): B-shared-wiring — reintroduce #10179 subset Files: 81 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { mkdtempSync, rmSync, truncateSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { NodeFileReadTooLargeError } from './node-bounded-file-reader'
|
|
import { RELAY_VERSION_MARKER_MAX_BYTES, readRelayVersionMarkerSync } from './relay-version-marker'
|
|
|
|
const roots: string[] = []
|
|
|
|
function createVersionFile(contents: string): string {
|
|
const root = mkdtempSync(join(tmpdir(), 'orca-relay-version-marker-'))
|
|
roots.push(root)
|
|
const filePath = join(root, '.version')
|
|
writeFileSync(filePath, contents)
|
|
return filePath
|
|
}
|
|
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) {
|
|
rmSync(root, { recursive: true, force: true })
|
|
}
|
|
})
|
|
|
|
describe('relay version marker', () => {
|
|
it('accepts a trimmed marker at the exact byte boundary', () => {
|
|
const version = '1.2.3+deadbeef'
|
|
const filePath = createVersionFile(
|
|
version + ' '.repeat(RELAY_VERSION_MARKER_MAX_BYTES - Buffer.byteLength(version))
|
|
)
|
|
|
|
expect(readRelayVersionMarkerSync(filePath)).toBe(version)
|
|
})
|
|
|
|
it('rejects a sparse marker one byte over the boundary', () => {
|
|
const filePath = createVersionFile('1.2.3')
|
|
truncateSync(filePath, RELAY_VERSION_MARKER_MAX_BYTES + 1)
|
|
|
|
expect(() => readRelayVersionMarkerSync(filePath)).toThrow(NodeFileReadTooLargeError)
|
|
})
|
|
})
|