Skip to content

Commit

Permalink
chore: update FileInfo fixture (#6181)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored Nov 13, 2024
1 parent 9607eb8 commit 03dffde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion http/etag_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ Deno.test({
Deno.test({
name: "eTag() handles Deno.FileInfo",
async fn() {
const fixture: Deno.FileInfo = {
const fixture = {
isFile: true,
isDirectory: false,
isSymlink: false,
size: 1024,
mtime: new Date(Date.UTC(96, 1, 2, 3, 4, 5, 6)),
atime: null,
ctime: null,
birthtime: null,
dev: 0,
ino: null,
Expand Down
16 changes: 8 additions & 8 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import denoConfig from "./deno.json" with { type: "json" };
import { MINUTE } from "@std/datetime/constants";
import { getAvailablePort } from "@std/net/get-available-port";
import { concat } from "@std/bytes/concat";
import { lessThan, parse as parseSemver } from "@std/semver";

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

const TEST_FILE_PATH = join(testdataDir, "test_file.txt");
const TEST_FILE_STAT = await Deno.stat(TEST_FILE_PATH);
Expand Down Expand Up @@ -188,10 +194,7 @@ Deno.test("serveDir() serves directory index", async () => {
assertStringIncludes(page, '<a href="/hello.html">hello.html</a>');
assertStringIncludes(page, '<a href="/tls/">tls/</a>');
assertStringIncludes(page, "%2525A.txt");
// `Deno.FileInfo` is not completely compatible with Windows yet
// TODO(bartlomieju): `mode` should work correctly in the future.
// Correct this test case accordingly.
if (Deno.build.os === "windows") {
if (fsModeUnavailable) {
assertMatch(page, /<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/);
} else {
assertMatch(page, /<td class="mode">(\s)*[a-zA-Z- ]{14}(\s)*<\/td>/);
Expand All @@ -212,10 +215,7 @@ Deno.test("serveDir() serves directory index with file containing space in the f
assertStringIncludes(page, '<a href="/hello.html">hello.html</a>');
assertStringIncludes(page, '<a href="/tls/">tls/</a>');
assertStringIncludes(page, "test%20file.txt");
// `Deno.FileInfo` is not completely compatible with Windows yet
// TODO(bartlomieju): `mode` should work correctly in the future.
// Correct this test case accordingly.
if (Deno.build.os === "windows") {
if (fsModeUnavailable) {
assertMatch(page, /<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/);
} else {
assertMatch(page, /<td class="mode">(\s)*[a-zA-Z- ]{14}(\s)*<\/td>/);
Expand Down

0 comments on commit 03dffde

Please sign in to comment.