Skip to content

Commit 03dffde

Browse files
authored
chore: update FileInfo fixture (#6181)
1 parent 9607eb8 commit 03dffde

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

http/etag_test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ Deno.test({
4242
Deno.test({
4343
name: "eTag() handles Deno.FileInfo",
4444
async fn() {
45-
const fixture: Deno.FileInfo = {
45+
const fixture = {
4646
isFile: true,
4747
isDirectory: false,
4848
isSymlink: false,
4949
size: 1024,
5050
mtime: new Date(Date.UTC(96, 1, 2, 3, 4, 5, 6)),
5151
atime: null,
52+
ctime: null,
5253
birthtime: null,
5354
dev: 0,
5455
ino: null,

http/file_server_test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import denoConfig from "./deno.json" with { type: "json" };
2222
import { MINUTE } from "@std/datetime/constants";
2323
import { getAvailablePort } from "@std/net/get-available-port";
2424
import { concat } from "@std/bytes/concat";
25+
import { lessThan, parse as parseSemver } from "@std/semver";
2526

2627
const moduleDir = dirname(fromFileUrl(import.meta.url));
2728
const testdataDir = resolve(moduleDir, "testdata");
@@ -32,6 +33,11 @@ const serveDirOptions: ServeDirOptions = {
3233
showDotfiles: true,
3334
enableCors: true,
3435
};
36+
const denoVersion = parseSemver(Deno.version.deno);
37+
const isCanary = denoVersion.build ? denoVersion.build.length > 0 : false;
38+
// FileInfo.mode is not available on Windows before Deno 2.1.0
39+
const fsModeUnavailable = Deno.build.os === "windows" &&
40+
lessThan(denoVersion, parseSemver("2.1.0")) && !isCanary;
3541

3642
const TEST_FILE_PATH = join(testdataDir, "test_file.txt");
3743
const TEST_FILE_STAT = await Deno.stat(TEST_FILE_PATH);
@@ -188,10 +194,7 @@ Deno.test("serveDir() serves directory index", async () => {
188194
assertStringIncludes(page, '<a href="/hello.html">hello.html</a>');
189195
assertStringIncludes(page, '<a href="/tls/">tls/</a>');
190196
assertStringIncludes(page, "%2525A.txt");
191-
// `Deno.FileInfo` is not completely compatible with Windows yet
192-
// TODO(bartlomieju): `mode` should work correctly in the future.
193-
// Correct this test case accordingly.
194-
if (Deno.build.os === "windows") {
197+
if (fsModeUnavailable) {
195198
assertMatch(page, /<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/);
196199
} else {
197200
assertMatch(page, /<td class="mode">(\s)*[a-zA-Z- ]{14}(\s)*<\/td>/);
@@ -212,10 +215,7 @@ Deno.test("serveDir() serves directory index with file containing space in the f
212215
assertStringIncludes(page, '<a href="/hello.html">hello.html</a>');
213216
assertStringIncludes(page, '<a href="/tls/">tls/</a>');
214217
assertStringIncludes(page, "test%20file.txt");
215-
// `Deno.FileInfo` is not completely compatible with Windows yet
216-
// TODO(bartlomieju): `mode` should work correctly in the future.
217-
// Correct this test case accordingly.
218-
if (Deno.build.os === "windows") {
218+
if (fsModeUnavailable) {
219219
assertMatch(page, /<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/);
220220
} else {
221221
assertMatch(page, /<td class="mode">(\s)*[a-zA-Z- ]{14}(\s)*<\/td>/);

0 commit comments

Comments
 (0)