Skip to content

Commit 7728647

Browse files
committed
Test large file
1 parent 9926756 commit 7728647

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/test/cache-github-live.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import {randomBytes} from 'node:crypto';
78
import {test} from 'uvu';
89
import * as assert from 'uvu/assert';
910
import {GitHubActionsCache} from '../caching/github-actions-cache.js';
@@ -44,7 +45,7 @@ test(
4445
assert.is(get1, undefined);
4546

4647
const filename = 'test';
47-
const content = 'This is a test file!';
48+
const content = randomBytes(200 * 1024 ** 2);
4849
await rig.write(filename, content);
4950
const set1 = await cache.set(script, fingerprint, [
5051
{
@@ -72,7 +73,7 @@ test(
7273
assert.not(await rig.exists('test'));
7374
await get2.apply();
7475
assert.ok(await rig.exists('test'));
75-
const actual = await rig.read('test');
76+
const actual = await rig.readBytes('test');
7677
console.log({actual});
7778
assert.equal(actual, content);
7879

src/test/util/filesystem-test-rig.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,21 @@ export class FilesystemTestRig {
131131
}
132132

133133
/**
134-
* Read a file from the temporary filesystem.
134+
* Read a file from the temporary filesystem as UTF8.
135135
*/
136136
async read(filename: string): Promise<string> {
137137
this._assertState('running');
138138
return fs.readFile(this.resolve(filename), 'utf8');
139139
}
140140

141+
/**
142+
* Read a file from the temporary filesystem as bytes.
143+
*/
144+
async readBytes(filename: string): Promise<Buffer<ArrayBufferLike>> {
145+
this._assertState('running');
146+
return fs.readFile(this.resolve(filename));
147+
}
148+
141149
/**
142150
* Check whether a file exists in the temporary filesystem.
143151
*/

0 commit comments

Comments
 (0)